Tabnine Logo
EnumValue.getKey
Code IndexAdd Tabnine to your IDE (free)

How to use
getKey
method
in
io.sphere.sdk.models.EnumValue

Best Java code snippets using io.sphere.sdk.models.EnumValue.getKey (Showing top 10 results out of 315)

origin: io.sphere.sdk.jvm/sphere-models

public static <T> AttributeDraft of(final String name, final T value) {
  final AttributeDraft result;
  if (value instanceof LocalizedEnumValue) {
    result = of(name, ((LocalizedEnumValue) value).getKey());
  } else if (value instanceof EnumValue) {
    result = of(name, ((EnumValue) value).getKey());
  } else if (value instanceof Set) {
    final Set<?> set = (Set<?>) value;
    if (!set.isEmpty()) {
      final Object setValue = set.stream().findAny().get();
      if (setValue instanceof LocalizedEnumValue || setValue instanceof EnumValue) {
        //WithKey is a interface the enum like implement
        final Set<String> newValues = set.stream().map(x -> ((WithKey) x).getKey()).collect(toSet());
        result = of(name, newValues);
      } else {
        result = of(name, SphereJsonUtils.toJsonNode(value));
      }
    } else {
      result = of(name, SphereJsonUtils.toJsonNode(value));
    }
  } else {
    result = of(name, SphereJsonUtils.toJsonNode(value));
  }
  return result;
}
origin: com.commercetools.sdk.jvm.core/commercetools-models

static <T> AttributeDraft of(final String name, final T value) {
  final AttributeDraft result;
  if (value instanceof LocalizedEnumValue) {
    result = of(name, ((LocalizedEnumValue) value).getKey());
  } else if (value instanceof EnumValue) {
    result = of(name, ((EnumValue) value).getKey());
  } else if (value instanceof Set) {
    final Set<?> set = (Set<?>) value;
    if (!set.isEmpty()) {
      final Object setValue = set.stream().findAny().get();
      if (setValue instanceof LocalizedEnumValue || setValue instanceof EnumValue) {
        //WithKey is a interface the enum like implement
        final Set<String> newValues = set.stream().map(x -> ((WithKey) x).getKey()).collect(toSet());
        result = of(name, newValues);
      } else {
        result = of(name, SphereJsonUtils.toJsonNode(value));
      }
    } else {
      result = of(name, SphereJsonUtils.toJsonNode(value));
    }
  } else {
    result = of(name, SphereJsonUtils.toJsonNode(value));
  }
  return result;
}
origin: commercetools/commercetools-jvm-sdk

static <T> AttributeDraft of(final String name, final T value) {
  final AttributeDraft result;
  if (value instanceof LocalizedEnumValue) {
    result = of(name, ((LocalizedEnumValue) value).getKey());
  } else if (value instanceof EnumValue) {
    result = of(name, ((EnumValue) value).getKey());
  } else if (value instanceof Set) {
    final Set<?> set = (Set<?>) value;
    if (!set.isEmpty()) {
      final Object setValue = set.stream().findAny().get();
      if (setValue instanceof LocalizedEnumValue || setValue instanceof EnumValue) {
        //WithKey is a interface the enum like implement
        final Set<String> newValues = set.stream().map(x -> ((WithKey) x).getKey()).collect(toSet());
        result = of(name, newValues);
      } else {
        result = of(name, SphereJsonUtils.toJsonNode(value));
      }
    } else {
      result = of(name, SphereJsonUtils.toJsonNode(value));
    }
  } else {
    result = of(name, SphereJsonUtils.toJsonNode(value));
  }
  return result;
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void facetedSearchOnEnumKeySetAttributes() throws Exception {
  testResultWithTerms(PRODUCT_MODEL.allVariants().attribute().ofEnumSet(ATTR_NAME_ENUM_SET).key().is(ENUM_THREE.getKey()),
      ids -> assertThat(ids).containsOnly(product1.getId()),
      termStats -> assertThat(termStats).containsExactly(
          TermStats.of(ENUM_TWO.getKey(), 2L),
          TermStats.of(ENUM_THREE.getKey(), 1L)));
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void onEnumKeySetAttributes() throws Exception {
  testTermStats(FACET.allVariants().attribute().ofEnumSet(ATTR_NAME_ENUM_SET).key().allTerms(),
      termStats -> assertThat(termStats).containsExactly(
          TermStats.of(ENUM_TWO.getKey(), 2L),
          TermStats.of(ENUM_THREE.getKey(), 1L)));
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void facetedSearchOnEnumKeyAttributes() throws Exception {
  testResultWithTerms(PRODUCT_MODEL.allVariants().attribute().ofEnum(ATTR_NAME_ENUM).key().is(ENUM_TWO.getKey()),
      ids -> assertThat(ids).containsOnly(product1.getId()),
      termStats -> assertThat(termStats).containsOnly(
          TermStats.of(ENUM_TWO.getKey(), 1L),
          TermStats.of(ENUM_THREE.getKey(), 1L)));
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void onEnumKeyAttributes() throws Exception {
  testTermStats(FACET.allVariants().attribute().ofEnum(ATTR_NAME_ENUM).key().allTerms(),
      termStats -> assertThat(termStats).containsOnly(
          TermStats.of(ENUM_TWO.getKey(), 1L),
          TermStats.of(ENUM_THREE.getKey(), 1L)));
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void changeEnumValueOrder() {
  withUpdateableType(client(), type -> {
    final String fieldName = TypeFixtures.ENUM_FIELD_NAME;
    final FieldType fieldType = type.getFieldDefinitionByName(fieldName).getType();
    final List<EnumValue> oldEnumValues = ((EnumFieldType) fieldType).getValues();
    final List<String> enumKeys = reverse(oldEnumValues.stream()
        .map(enumValue -> enumValue.getKey())
        .collect(Collectors.toList())
    );
    final Type updatedType = client().executeBlocking(TypeUpdateCommand.of(type, ChangeEnumValueOrder.of(fieldName, enumKeys)));
    final FieldType updatedFieldType = updatedType.getFieldDefinitionByName(fieldName).getType();
    final List<EnumValue> newEnumValues = ((EnumFieldType) updatedFieldType).getValues();
    assertThat(newEnumValues).containsAll(oldEnumValues);
    assertThat(newEnumValues.size()).isEqualTo(oldEnumValues.size());
    return updatedType;
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void onEnumKeySetAttributes() throws Exception {
  testProductIds(PRODUCT_MODEL.allVariants().attribute().ofEnumSet(ATTR_NAME_ENUM_SET).key().is(ENUM_THREE.getKey()),
      ids -> assertThat(ids).containsOnly(product1.getId()));
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void onEnumKeyAttributes() throws Exception {
  testProductIds(PRODUCT_MODEL.allVariants().attribute().ofEnum(ATTR_NAME_ENUM).key().is(ENUM_TWO.getKey()),
      ids -> assertThat(ids).containsOnly(product1.getId()));
}
io.sphere.sdk.modelsEnumValuegetKey

Popular methods of EnumValue

  • getLabel
  • of
  • typeReference

Popular in Java

  • Parsing JSON documents to java classes using gson
  • startActivity (Activity)
  • scheduleAtFixedRate (Timer)
  • setRequestProperty (URLConnection)
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • Path (java.nio.file)
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now