returns a sorted array of enum constants
484034
public GroovyFieldDoc[] enumConstants() {
        Collections.sort(enumConstants);
        return enumConstants.toArray(new GroovyFieldDoc[enumConstants.size()]);
    }
1088780
private String joinEnumNames(String separator) {
    E[] enumTypes = enumClass.getEnumConstants();
    StringBuilder sb = new StringBuilder();
    for(int i = 0; i < enumTypes.length; ++i) {
      if(i > 0) {
        sb.append(separator);
      }
      sb.append(enumTypes[i].name());
    }
    return sb.toString();
  }
1113000
private static function constants(): array
    {
        $class = get_called_class();

        if (isset(self::$constants[$class])) {
            return self::$constants[$class];
        }

        $reflection = new \ReflectionClass($class);

        return self::$constants[$class] = $reflection->getConstants();
    }
1275930
def choices(cls, blank=False):
        
        choices = sorted([(key, value) for key, value in cls.values.items()], key=lambda x: x[0])
        if blank:
            choices.insert(0, ('', Enum.Value('', None, '', cls)))
        return choices
96368
private @Nonnull List<SortableValue> enumsThatExist(BugAspects a) {
        List<Sortables> orderBeforeDivider = st.getOrderBeforeDivider();
        if (orderBeforeDivider.size() == 0) {
            List<SortableValue> result = Collections.emptyList();
            assert false;
            return result;
        }

        Sortables key;
        if (a.size() == 0) {
            key = orderBeforeDivider.get(0);
        } else {
            Sortables lastKey = a.last().key;
            int index = orderBeforeDivider.indexOf(lastKey);
            if (index + 1 < orderBeforeDivider.size()) {
                key = orderBeforeDivider.get(index + 1);
            } else {
                key = lastKey;
            }
        }

        String[] all = key.getAll(bugSet.query(a));
        ArrayList<SortableValue> result = new ArrayList<>(all.length);
        for (String i : all) {
            result.add(new SortableValue(key, i));
        }
        return result;

    }
422013
function enumeration(name, type, ...constants) {
  if (name[TYPICAL_TYPE]) {
    constants.unshift(type);
    type = name;
    name = `Some${type.name}Enum`;
  }

  /* istanbul ignore else */
  if (__DEV__) {
    assert(typeof name === 'string', `enum()'s name must be a string`);
    assert(type[TYPICAL_TYPE], `enum()'s type must be a type`);
    for (const constant of constants) {
      assert(type.is(constant), `enum()'s constant must have given type`);
    }
  }

  const api = this;

  function Enumeration(value, context) {
    if (Context.isRequired(context)) {
      return Context.with(value, Enumeration, context, api);
    }

    // All constants are guaranteed to have base type. See above.
    for (const constant of constants) {
      if (is(constant, value)) {
        return context.toValue(value, Enumeration);
      }
    }
    return context.valueIsNotOfType(value, Enumeration);
  }

  return decorate(Enumeration, name, enumeration, type, ...constants);
}
812077
protected function toListDeepProc($enum): array
    {
        $array = [];
        foreach ($enum as $v)
            $array[] = $v instanceof \Traversable || is_array($v) ? $this->toListDeepProc($v) : $v;
        return $array;
    }
323459
private Object getEnumValue(Class<?> type, Object value) {
        Object[] enumValues = type.getEnumConstants();
        for (Object enumValue : enumValues) {
            if (enumValue.toString().equals(value.toString())) {
                value = enumValue;
                break;
            }
        }
        return value;
    }
869786
public static function getConstants($include_default = false)
    {
        static::loadValues();
        $enumConstants = static::$enumConstants[get_called_class()];
        if (!$include_default) {
            unset($enumConstants['__DEFAULT']);
        }
        return $enumConstants;
    }
1060996
private String firstConstantOfEnum()
    {
        Object[] enumConstants = targetClass.getEnumConstants();

        if (enumConstants.length != 0)
        {
            return enumConstants[0].toString();
        }

        return ""; // if empty Enum
    }
859599
def get_enum_from_name(self, enum_name):
        
        return next((e for e in self.enums if e.name == enum_name), None)
1276359
public static <T extends Enum<T>> String[] enumNameToStringArray(T[] values) {

        int i = 0;
        String[] result = new String[values.length];
        for (T value : values) {
            result[i++] = value.name();
        }
        return result;
    }
835273
@SuppressWarnings("unchecked")
	public Object[] getEnumValues() {
		if (this.kind != Kind.ENUM)
			throw new RuntimeException("getEnumValues() can only be called on an enum");
		try {
			return MappingUtil.getEnumValues((Class<? extends Enum<?>>) getRawType());
		} catch (ClassNotFoundException e) {
			throw new RuntimeException(e);
		}
	}
20152
public ClassDoc[] enums() {
        ListBuffer<ClassDocImpl> ret = new ListBuffer<ClassDocImpl>();
        for (ClassDocImpl c : getClasses(true)) {
            if (c.isEnum()) {
                ret.append(c);
            }
        }
        return ret.toArray(new ClassDocImpl[ret.length()]);
    }
1236223
@SuppressWarnings("unchecked") // the cache always returns the type matching enumType
    public static <T extends Enum<T>> T[] getSharedConstants(Class<T> enumType) {
        return (T[]) sharedConstantsCache.get(enumType);
    }
80146
def _Enum(docstring, *names):
  
  enums = dict(zip(names, range(len(names))))
  reverse = dict((value, key) for key, value in enums.iteritems())
  enums['reverse_mapping'] = reverse
  enums['__doc__'] = docstring
  return type('Enum', (object,), enums)
961568
public static function enumTypes() {
        return [
            ButtonInterface::BUTTON_TYPE_DANGER,
            ButtonInterface::BUTTON_TYPE_DEFAULT,
            ButtonInterface::BUTTON_TYPE_INFO,
            ButtonInterface::BUTTON_TYPE_LINK,
            ButtonInterface::BUTTON_TYPE_PRIMARY,
            ButtonInterface::BUTTON_TYPE_SUCCESS,
            ButtonInterface::BUTTON_TYPE_WARNING,
        ];
    }