public String getStateYoVariableName() { return stateYoVariable.getName(); }
/** * Returns String representation of this YoEnum. * * @return String representing this YoEnum and its current value as an integer */ @Override public String toString() { return String.format("%s: %s", getName(), getStringValue()); }
private static <T extends Enum<T>> String getFormattedEnumYoVariable(final YoEnum<T> yoEnum) { String enumValueName = yoEnum.getEnumValue() != null ? yoEnum.getEnumValue().name() : "null"; return yoEnum.getName() + ":" + enumValueName; }
/** * Sets the YoEnum to the given enum. * * @param enumValue enum to set this YoEnum's internal enum state to * @param notifyListeners boolean determining whether or not to call {@link #notifyVariableChangedListeners()} * @return boolean if given value is valid and YoEnum is set or the same * @throws RuntimeException if enumValue is null and null values are disallowed for this YoEnum * @throws RuntimeException if enumValue ordinal falls out of allowed range for this YoEnum */ public boolean set(T enumValue, boolean notifyListeners) { checkIfBackedByEnum(); if (!allowNullValue && (enumValue == null)) { throw new RuntimeException( "Setting YoEnum " + getName() + " to null. Must set allowNullValue to true in the constructor if you ever want to set it to null."); } return set(enumValue == null ? NULL_VALUE : enumValue.ordinal(), notifyListeners); }
/** * Creates a new YoEnum with the same parameters as this one, and registers it to the passed {@link YoVariableRegistry}. * * @param newRegistry YoVariableRegistry to duplicate this YoEnum to * @return the newly created and registered YoEnum */ @Override public YoEnum<T> duplicate(YoVariableRegistry newRegistry) { YoEnum<T> retVar = new YoEnum<>(getName(), getDescription(), newRegistry, getEnumType(), getAllowNullValue()); retVar.set(getEnumValue()); return retVar; }