/** * The text representation of the {@link #name()}. * * This is formatted as lower case characters, with hyphens instead of spaces. */ public String value() { return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name()); }
/** @see #value() */ @Override public String toString() { return value(); }
/** * Creates a {@link Lifecycle} from a text representation. * * This accepts the text representations output by the {@link #value()} method for each entry. * * @see #value() */ public static Lifecycle fromValue(String v) { try { return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, v)); } catch (IllegalArgumentException iae) { return ON_FIRE; } } }
private ObjectNode entityBase(Entity entity) { ObjectNode aRoot = mapper.createObjectNode(); aRoot.put("name", entity.getDisplayName()); aRoot.put("id", entity.getId()); aRoot.put("type", entity.getEntityType().getName()); Boolean serviceUp = entity.getAttribute(Attributes.SERVICE_UP); if (serviceUp!=null) aRoot.put("serviceUp", serviceUp); Lifecycle serviceState = entity.getAttribute(Attributes.SERVICE_STATE); if (serviceState!=null) aRoot.put("serviceState", serviceState.toString()); String iconUrl = entity.getIconUrl(); if (iconUrl!=null) { if (brooklyn().isUrlServerSideAndSafe(iconUrl)) // route to server if it is a server-side url iconUrl = EntityTransformer.entityUri(entity)+"/icon"; aRoot.put("iconUrl", iconUrl); } return aRoot; }