Subversion Repositories SmartDukaan

Rev

Rev 25503 | Rev 26930 | 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
 
25652 amit.gupta 3
import java.util.AbstractMap;
4
import java.util.Arrays;
5
import java.util.List;
6
import java.util.Map;
7
import java.util.stream.Collectors;
8
import java.util.stream.Stream;
25503 amit.gupta 9
 
10
public enum PartnerType {
25652 amit.gupta 11
	ALL("All"), PLATINUM("Platinum"), DIAMOND("Diamond"), GOLD("Gold"), SILVER("Silver"), BRONZE("Bronze"),
25503 amit.gupta 12
	NEW("Rising Star");
25652 amit.gupta 13
	private static final List<PartnerType> partnerTypes = Arrays.asList(BRONZE, SILVER, GOLD, DIAMOND, PLATINUM);
25503 amit.gupta 14
	private String value;
25652 amit.gupta 15
 
16
	public static final Map<PartnerType, String> imageMap = Stream.of(
17
			new AbstractMap.SimpleEntry<>(PartnerType.GOLD, "resources/images/small_gold.png"), new AbstractMap.SimpleEntry<>(PartnerType.SILVER, "resources/images/small_silver.png"),
18
			new AbstractMap.SimpleEntry<>(PartnerType.NEW, "resources/images/small_risingstar.png"), new AbstractMap.SimpleEntry<>(PartnerType.PLATINUM, "resources/images/small_platinum.png"),
19
			new AbstractMap.SimpleEntry<>(PartnerType.BRONZE, "resources/images/small_bronze.png"),
20
			new AbstractMap.SimpleEntry<>(PartnerType.DIAMOND, "resources/images/small_diamond.png"))
21
			.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
22
 
25503 amit.gupta 23
	private PartnerType(String value) {
24
		this.value = value;
25
	}
25652 amit.gupta 26
 
25503 amit.gupta 27
	public String getValue() {
28
		return value;
29
	}
25652 amit.gupta 30
 
31
	public PartnerType next() {
32
		if (this.equals(PartnerType.NEW))
33
			return PartnerType.GOLD;
34
		int index = partnerTypes.indexOf(this);
35
		if (index + 1 == partnerTypes.size()) {
36
			return this;
37
		} else {
38
			return partnerTypes.get(index + 1);
39
		}
40
	}
41
 
42
	public PartnerType previous() {
43
		int index = partnerTypes.indexOf(this);
44
		if (index == 0) {
45
			return this;
46
		} else {
47
			return partnerTypes.get(index + 1);
48
		}
49
	}
25503 amit.gupta 50
}