public FieldMappingBuilder trySetFieldName(String fieldName){ if(Strings.isEmpty(this.fieldName)){ this.fieldName = fieldName; } return this; }
public static String getRequestUriWithQueryString(HttpServletRequest request) { StringBuilder uri = new StringBuilder(request.getRequestURI()); if(!Strings.isEmpty(request.getQueryString())){ uri.append('?').append(request.getQueryString()); } return uri.toString(); }
protected void readInclude(Resource resource, Map<String, Object> map) { String inc = (String) map.remove("@include"); if (!Strings.isEmpty(inc)) { readInclude(resource, map, inc); } }
public MTypeRef(String summary, String description, String refTypeName, String refTypeQName) { super(summary, description); Args.notEmpty(refTypeName, "refTypeName"); this.refTypeName = refTypeName; this.refTypeQName = Strings.isEmpty(refTypeQName) ? refTypeName : refTypeQName; }
@Override public SqlStatement createQueryStatement(QueryContext context, Object params) { //TODO : dynamic page query in jdbc clause if(null != context.getLimit()){ throw new UnsupportedOperationException("Dyanmic page query not implemented by " + this.getClass().getSimpleName()); } //TODO : dynamic order by in jdbc clause if(!Strings.isEmpty(context.getOrderBy())){ throw new UnsupportedOperationException("Dynamic order by not implemented by " + this.getClass().getSimpleName()); } return doCreateStatement(context, sql, params); }
@Override public String getErrorMessage(String title, MessageSource ms, Locale locale) { if(!Strings.isEmpty(errorMessage)){ return errorMessage; } if(!Strings.isEmpty(getMessageKey2())){ String m = ms.tryGetMessage(locale, messageKey2, getMessageArguments2(title)); return null == m ? messageKey2 : m; } return null; }
public static String prefixWithoutAndSuffixWithSlash(String path){ if(Strings.isEmpty(path)){ return path; } if(path.endsWith("/")){ return prefixWithoutSlash(path); }else{ return prefixWithoutSlash(path) + "/"; } }
@Override public String getRequiredAttribute(QName name) { String value = getAttribute(name); if(Strings.isEmpty(value)){ throw new IllegalStateException("Attribute '" + name + "' must not be empty, location : " + getCurrentLocation()); } return value; }
public String getRequiredAttribute(String localName) { String value = getAttribute(localName); if(Strings.isEmpty(value)){ throw new IllegalStateException("Attribute '" + localName + "' must not be empty, location : " + getCurrentLocation()); } return value; }
protected FieldMappingStrategy readFieldMappingStrategy(XmlReader reader) { String v = reader.getAttribute(MAPPING_STRATEGY_ATTRIBUTE); if(Strings.isEmpty(v)) { return FieldMappingStrategy.ALWAYS; }else{ return Enums.nameOf(FieldMappingStrategy.class, v); } }
@Override public Float getFloatAttribute(QName name) { String value = getAttribute(name); return Strings.isEmpty(value) ? null : Converts.convert(value, Float.class); }
@Override public float getFloatAttribute(String localName, float defaultValue) { String value = getAttribute(localName); return Strings.isEmpty(value) ? defaultValue : Converts.convert(value, Float.class); }
@Override public int resolveIntAttribute(QName name, int defaultValue) { String value = resolveAttribute(name); return Strings.isEmpty(value) ? defaultValue : Converts.toInt(value); }
@Override public float resolveFloatAttribute(QName name, int defaultValue) { String value = resolveAttribute(name); return Strings.isEmpty(value) ? defaultValue : Converts.convert(value, Float.class); }
private boolean isPluginEnabled(Plugin plugin, String prefix) { String enabled = config.getProperty(prefix + ".enabled"); if(Strings.isEmpty(enabled)) { return plugin.isDefaultEnabled(); }else { return Converts.toBoolean(enabled); } } }
@Override public State onAuthorizationDenied(Request request, Response response, SecurityContextHolder context) throws Throwable { if(!Strings.isEmpty(context.getDenyMessage())) { handler.forbidden(response, context.getDenyMessage()); }else { handler.forbidden(response); } return State.INTERCEPTED; } }
@Override protected Function<ActionParams, Object> createFunction(ApiConfigurator c, RestdContext context, RestdModel model) { MetaEntity entity = (MetaEntity)model.getAttribute(MetaEntity.class.getName()); if(null == entity || Strings.isEmpty(entity.getQueryView())) { return super.createFunction(c, context, model); }else { return new QueryFunctionEx(context.getApi(), context.getDao(), model, entity); } }
protected KeyAndDataSource resolveSqlIdentity(BeanDefinition bd, ReflectValued v, Inject inject) { String key = Strings.firstNotEmpty(inject.name(), inject.value()); SqlKey sk = v.getAnnotation(SqlKey.class); if (null != sk) { return resolveSqlIdentity(bd, v, sk); } if (Strings.isEmpty(key)) { key = v.getName(); } return new KeyAndDataSource(key, null); }
protected void mappingEntityByAnnotation(MetadataContext context, EntityMappingBuilder emb, Entity a){ if(null != a){ emb.setEntityName(Strings.firstNotEmpty(a.name(), a.value())); emb.setTableSchema(a.schema()); emb.setTableName(a.table()); emb.setTableNameDeclared(true); if(!Strings.isEmpty(a.secondaryTable())) { emb.setSecondaryTable(new DbTableBuilder(a.secondaryTable())); } mappingListenerByAnnotations(context, emb, a.listeners()); } }