/** * Create an mutable set contains specified elements * @param t1 one element to be added into the result set * @param ta an array from which all elements will be added into the result set * @param <T> the element type * @return a set that contains all elements specified */ public static <T> Set<T> newSet(T t1, T... ta) { Set<T> set = new DelegatingSet<>(); set.add(t1); Collections.addAll(set, ta); return set; }
@Override protected EnumSet<C.Feature> initFeatures() { EnumSet<C.Feature> fs = (data instanceof C.Set) ? ((C.Set<T>)data).features() : EnumSet.of(C.Feature.LIMITED); return fs; }
if (C.Set.class.isAssignableFrom(realComponentType)) { C.Set set = (C.Set) targetComponent; if (set.is(C.Feature.READONLY)) { C.Set newSet = C.newSet(set); targetComponent = newSet;
if (C.Set.class.isAssignableFrom(realComponentType)) { C.Set set = (C.Set) targetComponent; if (set.is(C.Feature.READONLY)) { C.Set newSet = C.newSet(set); targetComponent = newSet;
DelegatingSet(Collection<? extends T> c, boolean immutable) { if (c instanceof C.Set) { C.Set<T> set = (C.Set<T>) c; boolean setIsImmutable = set.is(C.Feature.IMMUTABLE); if (immutable && setIsImmutable) { data = set; } else { if (immutable) { data = Collections.unmodifiableSet(set); } else { data = new HashSet<T>(set); } } } else if (c instanceof java.util.Set) { Set<? extends T> set = (Set<? extends T>)c; if (immutable) { data = Collections.unmodifiableSet(set); } else { data = new HashSet<T>(set); } } else { Set<T> set = new HashSet<T>(c); if (immutable) { data = Collections.unmodifiableSet(set); } else { data = set; } } }
DelegatingSet(Collection<? extends T> c, boolean immutable) { if (c instanceof C.Set) { C.Set<T> set = (C.Set<T>) c; boolean setIsImmutable = set.is(C.Feature.IMMUTABLE); if (immutable && setIsImmutable) { data = set; } else { if (immutable) { data = Collections.unmodifiableSet(set); } else { data = new HashSet<T>(set); } } } else if (c instanceof java.util.Set) { Set<? extends T> set = (Set<? extends T>)c; if (immutable) { data = Collections.unmodifiableSet(set); } else { data = new HashSet<T>(set); } } else { Set<T> set = new HashSet<T>(c); if (immutable) { data = Collections.unmodifiableSet(set); } else { data = set; } } }
private void mergeFromWithList(final ControllerClassMetaInfoManager infoBase, final App app) { C.Set<String> withClasses = this.withList; if (withClasses.isEmpty()) { return; } ClassInfoRepository repo = app.classLoader().classInfoRepository(); for (final String withClass : withClasses) { String curWithClass = withClass; ControllerClassMetaInfo withClassInfo = infoBase.controllerMetaInfo(curWithClass); while (null == withClassInfo && !"java.lang.Object".equals(curWithClass)) { ClassNode node = repo.node(curWithClass); if (null != node) { node = node.parent(); } if (null == node) { break; } curWithClass = node.name(); withClassInfo = infoBase.controllerMetaInfo(curWithClass); } if (null != withClassInfo) { withClassInfo.merge(infoBase, app); interceptors.mergeFrom(withClassInfo.interceptors); } } }
private void mergeFromWithList(final ControllerClassMetaInfoManager infoBase, final App app) { C.Set<String> withClasses = this.withList; if (withClasses.isEmpty()) { return; } ClassInfoRepository repo = app.classLoader().classInfoRepository(); for (final String withClass : withClasses) { String curWithClass = withClass; ControllerClassMetaInfo withClassInfo = infoBase.controllerMetaInfo(curWithClass); while (null == withClassInfo && !"java.lang.Object".equals(curWithClass)) { ClassNode node = repo.node(curWithClass); if (null != node) { node = node.parent(); } if (null == node) { break; } curWithClass = node.name(); withClassInfo = infoBase.controllerMetaInfo(curWithClass); } if (null != withClassInfo) { withClassInfo.merge(infoBase, app); interceptors.mergeFrom(withClassInfo.interceptors); } } }
private void check(Map<String, Long> newTimestamps) { C.List<FsEvent> events = C.newSizedList(3); C.Set<String> set0 = C.set(timestamps.keySet()); C.Set<String> set1 = C.set(newTimestamps.keySet()); C.Set<String> added = set1.without(set0); if (!added.isEmpty()) { events.add(createEvent(FsEvent.Kind.CREATE, added)); } C.Set<String> removed = set0.without(set1); if (!removed.isEmpty()) { events.add(createEvent(FsEvent.Kind.DELETE, removed)); } C.Set<String> retained = set1.withIn(set0); C.Set<String> modified = modified(retained, newTimestamps); if (!modified.isEmpty()) { events.add(createEvent(FsEvent.Kind.MODIFY, modified)); } if (!events.isEmpty()) { trigger(events.toArray(new FsEvent[events.size()])); } }
private void check(Map<String, Long> newTimestamps) { C.List<FsEvent> events = C.newSizedList(3); C.Set<String> set0 = C.set(timestamps.keySet()); C.Set<String> set1 = C.set(newTimestamps.keySet()); C.Set<String> added = set1.without(set0); if (!added.isEmpty()) { events.add(createEvent(FsEvent.Kind.CREATE, added)); } C.Set<String> removed = set0.without(set1); if (!removed.isEmpty()) { events.add(createEvent(FsEvent.Kind.DELETE, removed)); } C.Set<String> retained = set1.withIn(set0); C.Set<String> modified = modified(retained, newTimestamps); if (!modified.isEmpty()) { events.add(createEvent(FsEvent.Kind.MODIFY, modified)); } if (!events.isEmpty()) { trigger(events.toArray(new FsEvent[events.size()])); } }
public static <T> Set<T> intercectionOf(Collection<? extends T> col1, Collection<? extends T> col2) { return C.set(col1).withIn(col2); }
public static boolean isInterceptorAnnotation(Class<? extends Annotation> type) { return INTERCEPTOR_ANNOTATION_TYPES.contains(type); }
public static boolean isEnvAnnoDescriptor(String descriptor) { return ENV_ANNO_DESCS.contains(descriptor); }
private void _addWith(String clsName) { withList.add(Type.getType(clsName).getClassName()); }
public static <T> Set<T> intercectionOf(Collection<? extends T> col1, Collection<? extends T> col2) { return C.set(col1).withIn(col2); }
public Set<$.Binary<K, V>> zip() { C.Set<$.Binary<K, V>> zipped = C.newSet(); for (java.util.Map.Entry<K, V> entry : entrySet()) { zipped.add($.T2(entry.getKey(), entry.getValue())); } return zipped; }
public static boolean isActionAnnotation(Class<? extends Annotation> type) { return ACTION_ANNOTATION_TYPES.contains(type); }
public static boolean isEnvAnnotation(Class<? extends Annotation> type) { return ENV_ANNOTATION_TYPES.contains(type); }