/** * Exists. * * @param state * the {@link State} to search for this {@link StateEntry} * @return {@code true} is specified {@code state} contains this * {@link StateEntry}'s key, {@code false} otherwise * @see java.util.Map#containsKey(Object) */ public boolean exists(final State state) { return state.containsKey(getKey()); }
/** * Sets the id. * * @param id * the new id */ public void setId(final String id) { this.put("id", id); }
/** * Load state. * * @param sc * the sc */ private void loadState(final ObjectNode sc) { if (sc != null) { final StateConfig stateConfig = new StateConfig(sc); if (agentId != null && stateConfig.getId() == null) { stateConfig.setId(agentId); } state = new StateBuilder().withConfig(stateConfig).build(); config.set("state", stateConfig); } }
/** * Load. */ public void load() { if (state != null) { agents = state.get("agents", new TypeUtil<HashMap<String, WakeEntry>>() { }); } }
@Override public void delete() { // TODO: clear out all state files final State state = new StateBuilder().withConfig( (ObjectNode) myParams.get("state")).build(); if (state != null) { state.delete(); } }
/** * Gets the value. * * @param state * the {@link State} from which to retrieve this * @return the value retrieved from specified {@code state} or {@code null} * if none exists {@code StateEntry}'s value * @see java.util.Map#get(Object) */ public T getValue(final State state) { try { return state.get(getKey(), valueType); } catch (final ClassCastException e) { LOG.log(Level.WARNING, "Problem casting agent's state value, key: " + key, e); return null; } }
/** * Store. */ public void store() { if (state != null) { state.put("agents", agents); } }
@Override public void delete(final State instance) { STATES.remove(instance.getId()); }
/** * Put value if unchanged. * * @param state * the {@link State} to update with specified {@code value} * @param newValue * the new value for this {@link StateEntry} in specified * @param currentValue * the current/precondition value for this {@link StateEntry} in * specified {@code state} * @return the previous value or {@code null} if none existed {@code state} */ public boolean putValueIfUnchanged(final State state, final T newValue, final T currentValue) { return state.putIfUnchanged(getKey(), newValue, currentValue); }
@Id @Override public String getId() { return super.getId(); }
/** * get meeting activity returns null if no activity has been initialized. * @return activity */ public Activity getActivity() { return getState().get("activity",Activity.class); }
/** * Remove all issues */ private void clearIssues() { getState().remove("issues"); }
/** * Get the username associated with the tasks * @return name */ @Override public String getUsername() { return getState().get("name",String.class); }
/** * Get the username associated with the calendar * * @return name */ @Override public String getUsername() { return getState().get("name", String.class); }
/** * Get the email associated with the calendar * * @return email */ @Override public String getEmail() { return getState().get("email", String.class); }
/** * Get the email associated with the tasks * @return name */ @Override public String getEmail() { return getState().get("email",String.class); }