/** * Convenient method to add a parameter of type {@link String}. * * @param key * current ley of the parameters * @param value * value of the parameter */ public void putDate(String key, Date value) { this.addValue(key, value); }
/** * Convenient method to get a string value. * * @param key * current key * @param required * if value is required */ public Boolean getBoolean(String key) { return this.getBoolean(key, false); }
/** * Convenient method to get a string value. * * @param key * current key * @param required * if value is required */ public Date getDate(String key) { return this.getDate(key, false); }
public Boolean check(String featureUID, Map<String, String> map) { featureValidator.assertFeatureExists(featureUID); FlippingExecutionContext flipExecCtx = new FlippingExecutionContext(); for (Map.Entry<String, String> entry : map.entrySet()) { flipExecCtx.putString(entry.getKey(), entry.getValue()); } return ff4j.check(featureUID, flipExecCtx); } }
/** * Initialize flipping execution context. * * @return * get current context */ public FlippingExecutionContext getCurrentContext() { if (!initialized) { init(); } if (null == this.currentExecutionContext.get()) { this.currentExecutionContext.set(new FlippingExecutionContext()); } return this.currentExecutionContext.get(); }
/** {@inheritDoc} */ @Override public boolean evaluate(String featureName, FeatureStore store, FlippingExecutionContext executionContext) { if (null == executionContext || !executionContext.containsKey(CLIENT_HOSTNAME)) { throw new IllegalArgumentException("To work with " + getClass().getName() + " you must provide '" + CLIENT_HOSTNAME + "' parameter in execution context"); } return setOfGrantedClient.contains(executionContext.getString(CLIENT_HOSTNAME)); }
/** {@inheritDoc} */ @Override public boolean evaluate(String featureName, FeatureStore store, FlippingExecutionContext executionContext) { // Check current date agains interval Calendar now = Calendar.getInstance(); if (executionContext != null && executionContext.containsKey(OVERRIDE_DATE)) { now = (Calendar) executionContext.getValue(OVERRIDE_DATE, false); } // Priority 1 : Special Opening String currentDate = SDF_DATE.format(now.getTime()); if (specialTimeTable.containsKey(currentDate)) { // Today is in special openings, apply return matches(now, specialTimeTable.get(currentDate)); } // Priority 2 : Public Holiday => CLOSED if (publicHolidays.contains(currentDate)) { return false; } // Default behavior, get current day, retrive intervals and check return matches(now, weekTimeTable.get(now.get(Calendar.DAY_OF_WEEK))); }
/** * Convenient method to get a string value. * * @param key * current key * @param required * if value is required */ public Double getDouble(String key) { return this.getDouble(key, false); }
/** {@inheritDoc} */ protected boolean eval(FF4j ff4j, PageContext jspContext) { FlippingExecutionContext executionContext = new FlippingExecutionContext(); if (isShareHttpSession()) { executionContext.putString("LOCALE", pageContext.getRequest().getLocalName()); @SuppressWarnings("unchecked") Map < String, String[]> parameters = pageContext.getRequest().getParameterMap(); for (Map.Entry<String,String[]> param : parameters.entrySet()) { String[] innerParams = param.getValue(); if (innerParams != null) { StringBuilder sb = new StringBuilder(); for (String innerParam : innerParams) { sb.append(innerParam); sb.append(","); } String expression = sb.toString(); executionContext.putString(param.getKey(), expression.substring(0, expression.length() - 1)); } } } return !ff4j.check(getFeatureid(), executionContext); }
FlippingExecutionContext context = new FlippingExecutionContext(); this.currentExecutionContext.set(context);
/** {@inheritDoc} */ @Override public boolean evaluate(String featureName, FeatureStore store, FlippingExecutionContext ctx) { if (null != ctx && ctx.containsKey(SERVER_HOSTNAME)) { return setOfTargetServer.contains(ctx.getString(SERVER_HOSTNAME)); } return setOfTargetServer.contains(IOUtil.resolveHostName()); }
/** {@inheritDoc} */ protected boolean eval(FF4j ff4j, PageContext jspContext) { FlippingExecutionContext executionContext = new FlippingExecutionContext(); if (isShareHttpSession()) { executionContext.putString("LOCALE", pageContext.getRequest().getLocalName()); @SuppressWarnings("unchecked") Map < String, String[]> parameters = pageContext.getRequest().getParameterMap(); for (Map.Entry<String,String[]> param : parameters.entrySet()) { String[] innerParams = param.getValue(); if (innerParams != null) { StringBuilder sb = new StringBuilder(); for (String innerParam : innerParams) { sb.append(innerParam); sb.append(","); } String expression = sb.toString(); executionContext.putString(param.getKey(), expression.substring(0, expression.length() - 1)); } } } return ff4j.check(getFeatureid(), executionContext); }
/** {@inheritDoc} */ @Override public boolean evaluate(String featureName, FeatureStore currentStore, FlippingExecutionContext executionContext) { // If execution context specified overriding initvalue if ((null != executionContext) && executionContext.containsKey(PARAM_EXPRESSION)) { return evaluateExpression(executionContext.getString(PARAM_EXPRESSION), currentStore,executionContext); } else if (mapOfValue.containsKey(featureName)) { // Else, check initial value of featureName (if exist) return evaluateExpression(mapOfValue.get(featureName), currentStore, executionContext); } // FeatureName does not exit, no condition required return true; }
/** * Convenient method to add a parameter of type {@link String}. * * @param key * current ley of the parameters * @param value * value of the parameter */ public void putInt(String key, Integer value) { this.addValue(key, value); }
FlippingExecutionContext flipExecCtx = new FlippingExecutionContext(); for (String key : formParams.keySet()) { flipExecCtx.putString(key, formParams.getFirst(key));
/** * Convenient method to add a parameter of type {@link String}. * * @param key * current ley of the parameters * @param value * value of the parameter */ public void putString(String key, String value) { this.addValue(key, value); }
/** * Convenient method to add a parameter of type {@link String}. * * @param key * current ley of the parameters * @param value * value of the parameter */ public void putBoolean(String key, Boolean value) { this.addValue(key, value); }
/** * Convenient method to add a parameter of type {@link String}. * * @param key * current ley of the parameters * @param value * value of the parameter */ public void putDouble(String key, Double value) { this.addValue(key, value); }