public interface SphereEnumeration
Hints for importing SphereEnumerations:
final List<String> javaValues = asList("None", "Unique", "CombinationUnique", "SameForAll"); final List<AttributeConstraint> enumValueNames = javaValues.stream() .map(value -> AttributeConstraint.ofSphereValue(value)) .collect(toList()); assertThat(enumValueNames) .as("use ofSphereValue(value) for importing from commercetools platform constants") .containsExactly(NONE, UNIQUE, COMBINATION_UNIQUE, SAME_FOR_ALL);See the test code.
final List<String> javaValues = asList("NONE", "UNIQUE", "COMBINATION_UNIQUE", "SAME_FOR_ALL"); final List<AttributeConstraint> enumValueNames = javaValues.stream() .map(value -> AttributeConstraint.valueOf(value)) .collect(toList()); assertThat(enumValueNames) .as("use valueOf(value) for importing the upper case values") .containsExactly(NONE, UNIQUE, COMBINATION_UNIQUE, SAME_FOR_ALL);See the test code.
Hints for exporting SphereEnumerations:
final List<AttributeConstraint> javaValues = asList(NONE, UNIQUE, COMBINATION_UNIQUE, SAME_FOR_ALL); final List<String> enumValueNames = javaValues.stream() .map(value -> value.toSphereName()) .collect(toList()); assertThat(enumValueNames) .as("use toSphereName() for constants used in the commercetools platform") .containsExactly("None", "Unique", "CombinationUnique", "SameForAll");See the test code.
final List<AttributeConstraint> javaValues = asList(NONE, UNIQUE, COMBINATION_UNIQUE, SAME_FOR_ALL); final List<String> enumValueNames = javaValues.stream() .map(value -> value.name()) .collect(toList()); assertThat(enumValueNames) .as("use name() for upper case values") .containsExactly("NONE", "UNIQUE", "COMBINATION_UNIQUE", "SAME_FOR_ALL");See the test code.
| Modifier and Type | Method and Description |
|---|---|
static <T extends Enum<T>> |
findBySphereName(T[] values,
String sphereName) |
String |
name() |
default String |
toSphereName() |