Package org.grouplens.common.dto.Dto

Examples of org.grouplens.common.dto.Dto.Named


    private class DtoContainerSerializer implements JsonSerializer<DtoContainer<?>>, JsonDeserializer<DtoContainer<?>> {
        private final ConcurrentMap<String, Class<? extends Dto>> singleDtoMap = new ConcurrentHashMap<String, Class<? extends Dto>>();
        private final ConcurrentMap<String, Class<? extends Dto>> pluralDtoMap = new ConcurrentHashMap<String, Class<? extends Dto>>();
       
        public void registerType(Class<? extends Dto> type) {
            Named typeName = type.getAnnotation(Named.class);
            String single = getDtoSingularName(type, typeName);
            String plural = getDtoPluralName(single, typeName);
           
            // in the event that registerType is called simultaneously with
            // the same type, we're still okay since getDtoXName() will return
View Full Code Here


        }
       
        @Override
        public JsonElement serialize(DtoContainer<?> src, Type typeOfSrc, JsonSerializationContext context) {
            Class<? extends Dto> type = src.getDtoType();
            Named typeName = type.getAnnotation(Named.class);
           
            String single = getDtoSingularName(type, typeName);
            JsonObject wrapper = new JsonObject();
           
            if(src.isMultiValued()) {
View Full Code Here

     */
    private static class DtoNamingStrategy implements FieldNamingStrategy {
       
        @Override
        public String translateName(Field f) {
            Named n = f.getAnnotation(Named.class);
            if (n != null) {
                return (f.getType().isArray() ? n.plural() : n.singular());
            } else
                return f.getName();
        }
View Full Code Here

    }
    return false;
  }

  private static String translateFieldName(Field f) {
    Named named = f.getAnnotation(Named.class);
    if (named != null) {
      return f.getType().isArray() ? named.plural() : named.singular();
    } else {
      return f.getName();
    }
  }
View Full Code Here

      return f.getName();
    }
  }

  private static String getDtoSingularName(Class<? extends Dto> type) {
    Named name = type.getAnnotation(Named.class);
    if (name != null) {
      return name.singular();
    } else {
      // if the first letter is capitalized, make it lower case.
      String derived = type.getSimpleName();
      String suffix = "Dto";
      derived = Character.toLowerCase(derived.charAt(0)) + derived.substring(1);
View Full Code Here

      return derived;
    }
  }

  private static String getDtoPluralName(Class<? extends Dto> type) {
    Named name = type.getAnnotation(Named.class);
    if (name != null) {
      return name.plural();
    } else {
      // Dto default names always assumed to be singular
      return getDtoSingularName(type) + "s";
    }
  }
View Full Code Here

TOP

Related Classes of org.grouplens.common.dto.Dto.Named

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.