private StringRange(String token) { Builder b = new Builder(token); this.type = b.type; this.qValue = b.qValue; this.extensions = unmodifiableMap(b.extensions); }
MediaType(String mt) { Builder b = new Builder(mt); this.mediaType = b.mediaType; this.type = b.type; this.subType = b.subType; this.subTypes = b.subTypes; this.subTypesSorted = b.subTypesSorted; this.subTypesList = immutableList(subTypes); this.parameters = unmodifiableMap(b.parameters); this.hasSubtypeMeta = b.hasSubtypeMeta; }
/** * Collapses a collection of individual objects, arrays, and collections into a single list of objects. * * @param o The collection of objects to collapse. * @return A new linked-list of objects. */ public static List<Object> collapse(Object...o) { return collapse(new LinkedList<>(), o); }
/** * Constructor. * * @param vars The Var classes used for resolving string variables. * @param contextObjects Read-only context objects. */ public VarResolverContext(Class<? extends Var>[] vars, Map<String,Object> contextObjects) { this.vars = Arrays.copyOf(vars, vars.length); Map<String,Var> m = new ConcurrentSkipListMap<>(); for (Class<?> c : vars) { if (! isParentClass(Var.class, c)) throw new VarResolverException("Invalid variable class. Must extend from Var"); Var v = newInstance(Var.class, c); m.put(v.getName(), v); } this.varMap = unmodifiableMap(m); this.contextObjects = immutableMap(contextObjects); }
/** * Constructor * * @param encoders The encoders to add to this group. */ public EncoderGroup(Encoder[] encoders) { this.encoders = immutableList(encoders); List<String> lc = new ArrayList<>(); List<Encoder> l = new ArrayList<>(); for (Encoder e : encoders) { for (String c: e.getCodings()) { lc.add(c); l.add(e); } } this.encodings = lc.toArray(new String[lc.size()]); this.encodingsList = unmodifiableList(lc); this.encodingsEncoders = l.toArray(new Encoder[l.size()]); }
ConfigEntry(String key, String value, String modifiers, String comment, List<String> preLines) { this.rawLine = null; this.key = key; this.value = value; this.comment = comment; this.modifiers = modifiers; this.preLines = immutableList(preLines); }
/** * Constructor. * * @param mediaType The resource media type. * @param headers The HTTP response headers for this streamed resource. * @param cached * Identifies if this stream resource is cached in memory. * <br>If <jk>true</jk>, the contents will be loaded into a byte array for fast retrieval. * @param contents * The resource contents. * <br>If multiple contents are specified, the results will be concatenated. * <br>Contents can be any of the following: * <ul> * <li><code><jk>byte</jk>[]</code> * <li><code>InputStream</code> * <li><code>Reader</code> - Converted to UTF-8 bytes. * <li><code>File</code> * <li><code>CharSequence</code> - Converted to UTF-8 bytes. * </ul> * @throws IOException */ public StreamResource(MediaType mediaType, Map<String,Object> headers, boolean cached, Object...contents) throws IOException { this.mediaType = mediaType; this.headers = immutableMap(headers); this.contents = cached ? new Object[]{readBytes(contents)} : contents; }
/** * Registers the specified serializers with this group. * * @param s The serializers to append to this group. * @return This object (for method chaining). */ public SerializerGroupBuilder append(Class<?>...s) { addReverse(serializers, s); return this; }
/** * Same as {@link #getAnnotationsMap(Class, Type)} except returns results in parent-to-child order. * * @param <T> The annotation class type. * @param a The annotation class type. * @param t The class being searched. * @return The found matches, or an empty map if annotation was not found. */ public static <T extends Annotation> LinkedHashMap<Class<?>,T> getAnnotationsMapParentFirst(Class<T> a, Type t) { return CollectionUtils.reverse(getAnnotationsMap(a, t)); }
/** * Finds and appends the specified annotation on the specified class and superclasses/interfaces to the specified * list. * * @param a The annotation. * @param t The class. * @param l The list of annotations. */ public static <T extends Annotation> void appendAnnotations(Class<T> a, Type t, List<T> l) { Class<?> c = toClass(t); if (c != null) { addIfNotNull(l, getDeclaredAnnotation(a, c)); if (c.getPackage() != null) addIfNotNull(l, c.getPackage().getAnnotation(a)); appendAnnotations(a, c.getSuperclass(), l); for (Class<?> c2 : c.getInterfaces()) appendAnnotations(a, c2, l); } }
/** * Constructor. * * @param vars The Var classes used for resolving string variables. * @param contextObjects Read-only context objects. */ public VarResolverContext(Class<? extends Var>[] vars, Map<String,Object> contextObjects) { this.vars = Arrays.copyOf(vars, vars.length); Map<String,Var> m = new ConcurrentSkipListMap<>(); for (Class<?> c : vars) { if (! isParentClass(Var.class, c)) throw new VarResolverException("Invalid variable class. Must extend from Var"); Var v = newInstance(Var.class, c); m.put(v.getName(), v); } this.varMap = unmodifiableMap(m); this.contextObjects = immutableMap(contextObjects); }
/** * Constructor * * @param encoders The encoders to add to this group. */ public EncoderGroup(Encoder[] encoders) { this.encoders = immutableList(encoders); List<String> lc = new ArrayList<>(); List<Encoder> l = new ArrayList<>(); for (Encoder e : encoders) { for (String c: e.getCodings()) { lc.add(c); l.add(e); } } this.encodings = lc.toArray(new String[lc.size()]); this.encodingsList = unmodifiableList(lc); this.encodingsEncoders = l.toArray(new Encoder[l.size()]); }
ConfigEntry(String key, String value, String modifiers, String comment, List<String> preLines) { this.rawLine = null; this.key = key; this.value = value; this.comment = comment; this.modifiers = modifiers; this.preLines = immutableList(preLines); }
/** * Constructor. * * @param mediaType The resource media type. * @param headers The HTTP response headers for this streamed resource. * @param cached * Identifies if this resource is cached in memory. * <br>If <jk>true</jk>, the contents will be loaded into a String for fast retrieval. * @param contents * The resource contents. * <br>If multiple contents are specified, the results will be concatenated. * <br>Contents can be any of the following: * <ul> * <li><code>InputStream</code> * <li><code>Reader</code> - Converted to UTF-8 bytes. * <li><code>File</code> * <li><code>CharSequence</code> - Converted to UTF-8 bytes. * </ul> * @throws IOException */ public ReaderResource(MediaType mediaType, Map<String,Object> headers, boolean cached, Object...contents) throws IOException { this.mediaType = mediaType; this.headers = immutableMap(headers); this.contents = cached ? new Object[]{readAll(contents)} : contents; }
/** * Registers the specified encoders with this group. * * @param e The encoders to append to this group. * @return This object (for method chaining). */ public EncoderGroupBuilder append(Encoder...e) { addReverse(encoders, e); return this; }
/** * Same as {@link #getAnnotationsMap(Class, Type)} except returns results in parent-to-child order. * * @param <T> The annotation class type. * @param a The annotation class type. * @param t The class being searched. * @return The found matches, or an empty map if annotation was not found. */ public static <T extends Annotation> LinkedHashMap<Class<?>,T> getAnnotationsMapParentFirst(Class<T> a, Type t) { return CollectionUtils.reverse(getAnnotationsMap(a, t)); }
/** * Finds and appends the specified annotation on the specified class and superclasses/interfaces to the specified * list. * * @param a The annotation. * @param t The class. * @param l The list of annotations. */ public static <T extends Annotation> void appendAnnotations(Class<T> a, Type t, List<T> l) { Class<?> c = toClass(t); if (c != null) { addIfNotNull(l, getDeclaredAnnotation(a, c)); if (c.getPackage() != null) addIfNotNull(l, c.getPackage().getAnnotation(a)); appendAnnotations(a, c.getSuperclass(), l); for (Class<?> c2 : c.getInterfaces()) appendAnnotations(a, c2, l); } }
private MediaTypeRange(String token) { Builder b = new Builder(token); this.mediaType = b.mediaType; this.qValue = b.qValue; this.extensions = unmodifiableMap(b.extensions); }
MediaType(String mt) { Builder b = new Builder(mt); this.mediaType = b.mediaType; this.type = b.type; this.subType = b.subType; this.subTypes = b.subTypes; this.subTypesSorted = b.subTypesSorted; this.subTypesList = immutableList(subTypes); this.parameters = unmodifiableMap(b.parameters); this.hasSubtypeMeta = b.hasSubtypeMeta; }
/** * Constructor. * * @param vars The Var classes used for resolving string variables. * @param contextObjects Read-only context objects. */ public VarResolverContext(Class<? extends Var>[] vars, Map<String,Object> contextObjects) { this.vars = Arrays.copyOf(vars, vars.length); Map<String,Var> m = new ConcurrentSkipListMap<>(); for (Class<?> c : vars) { if (! isParentClass(Var.class, c)) throw new VarResolverException("Invalid variable class. Must extend from Var"); Var v = newInstance(Var.class, c); m.put(v.getName(), v); } this.varMap = unmodifiableMap(m); this.contextObjects = immutableMap(contextObjects); }