@Override public EnumTypeDefinition buildType() { final Map<String, EnumPair> map = builder.build(); final Map<Integer, EnumPair> positionMap = new HashMap<>(); for (EnumPair p : map.values()) { final EnumPair conflict = positionMap.put(p.getValue(), p); if (conflict != null) { throw new InvalidEnumDefinitionException(p, "Enum '%s' conflicts on value with enum ", conflict); } } return getBaseType() == null ? new BaseEnumerationType(getPath(), getUnknownSchemaNodes(), map.values()) : new RestrictedEnumerationType(getBaseType(), getPath(), getUnknownSchemaNodes(), map.values()); } }
@Override public EnumTypeDefinition buildType() { final Map<String, EnumPair> map = builder.build(); final Map<Integer, EnumPair> positionMap = new HashMap<>(); for (EnumPair p : map.values()) { final EnumPair conflict = positionMap.put(p.getValue(), p); if (conflict != null) { throw new InvalidEnumDefinitionException(p, "Enum '%s' conflicts on value with enum ", conflict); } } return getBaseType() == null ? new BaseEnumerationType(getPath(), getUnknownSchemaNodes(), map.values()) : new RestrictedEnumerationType(getBaseType(), getPath(), getUnknownSchemaNodes(), map.values()); } }
public EnumerationTypeBuilder addEnum(final @NonNull EnumPair item) { // in case we are dealing with a restricted enumeration type, validate if the enum is a subset of its base type final EnumTypeDefinition base = getBaseType(); if (base != null) { validateRestrictedEnum(item, base); } builder.put(item.getName(), item); touch(); return this; }
public EnumerationTypeBuilder addEnum(final @NonNull EnumPair item) { // in case we are dealing with a restricted enumeration type, validate if the enum is a subset of its base type final EnumTypeDefinition base = getBaseType(); if (base != null) { validateRestrictedEnum(item, base); } builder.put(item.getName(), item); touch(); return this; }