Subversion Repositories SmartDukaan

Rev

Rev 27797 | Rev 31523 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
25503 amit.gupta 1
package com.spice.profitmandi.dao.entity.fofo;
2
 
31522 amit.gupta 3
import org.apache.commons.collections4.list.UnmodifiableList;
4
 
5
import java.util.*;
25652 amit.gupta 6
import java.util.stream.Collectors;
7
import java.util.stream.Stream;
25503 amit.gupta 8
 
9
public enum PartnerType {
25652 amit.gupta 10
	ALL("All"), PLATINUM("Platinum"), DIAMOND("Diamond"), GOLD("Gold"), SILVER("Silver"), BRONZE("Bronze"),
25503 amit.gupta 11
	NEW("Rising Star");
26930 amit.gupta 12
 
27797 tejbeer 13
	private static final List<PartnerType> partnerTypes = new UnmodifiableList<>(
14
			Arrays.asList(BRONZE, SILVER, GOLD, DIAMOND, PLATINUM));
15
 
26930 amit.gupta 16
	public static final Map<PartnerType, Integer> PartnerTypeRankMap = new HashMap<>();
17
 
18
	static {
19
		PartnerTypeRankMap.put(PartnerType.BRONZE, 1);
20
		PartnerTypeRankMap.put(PartnerType.SILVER, 2);
21
		PartnerTypeRankMap.put(PartnerType.GOLD, 3);
22
		PartnerTypeRankMap.put(PartnerType.DIAMOND, 4);
23
		PartnerTypeRankMap.put(PartnerType.PLATINUM, 5);
24
		PartnerTypeRankMap.put(PartnerType.NEW, 6);
25
 
26
	}
25503 amit.gupta 27
	private String value;
25652 amit.gupta 28
 
26930 amit.gupta 29
	public static final Map<PartnerType, String> imageMap = Stream
31522 amit.gupta 30
			.of(new AbstractMap.SimpleEntry<>(PartnerType.GOLD, "resources/images/small-gold.png"),
31
					new AbstractMap.SimpleEntry<>(PartnerType.SILVER, "resources/images/small-silver.png"),
32
					new AbstractMap.SimpleEntry<>(PartnerType.NEW, "resources/images/small-risingstar.png"),
33
					new AbstractMap.SimpleEntry<>(PartnerType.PLATINUM, "resources/images/small-platinum.png"),
34
					new AbstractMap.SimpleEntry<>(PartnerType.BRONZE, "resources/images/small-bronze.png"),
35
					new AbstractMap.SimpleEntry<>(PartnerType.DIAMOND, "resources/images/small-diamond.png"))
25652 amit.gupta 36
			.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
37
 
25503 amit.gupta 38
	private PartnerType(String value) {
39
		this.value = value;
40
	}
25652 amit.gupta 41
 
25503 amit.gupta 42
	public String getValue() {
43
		return value;
44
	}
25652 amit.gupta 45
 
46
	public PartnerType next() {
47
		if (this.equals(PartnerType.NEW))
48
			return PartnerType.GOLD;
49
		int index = partnerTypes.indexOf(this);
50
		if (index + 1 == partnerTypes.size()) {
51
			return this;
52
		} else {
53
			return partnerTypes.get(index + 1);
54
		}
55
	}
27797 tejbeer 56
 
57
	public List<PartnerType> nextPartnerTypes() {
58
		if (this.equals(PartnerType.NEW))
59
			return Arrays.asList(this);
60
		int index = partnerTypes.indexOf(this);
61
		return partnerTypes.stream().skip(index + 1).collect(Collectors.toList());
62
 
63
	}
25503 amit.gupta 64
}