Java Code Examples for org.osgl.util.C#newSet()

The following examples show how to use org.osgl.util.C#newSet() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SecureTicketCodec.java    From actframework with Apache License 2.0 6 votes vote down vote up
@Override
public final T createTicket(H.Session session) {
    String id = session.id();
    Map<String, String> map = new HashMap<>();
    Set<String> keys = this.keys;
    if (keys.isEmpty()) {
        keys = C.newSet(session.keySet());
        keys.remove(H.Session.KEY_EXPIRATION);
        keys.remove(H.Session.KEY_ID);
    }
    for (String key : keys) {
        String val = session.get(key);
        if (null != val) {
            map.put(key, val);
        }
    }
    return serialize(id, map);
}
 
Example 2
Source File: ControllerClassMetaInfo.java    From actframework with Apache License 2.0 6 votes vote down vote up
private void mergeFromWithList(final ControllerClassMetaInfoManager infoBase, final App app) {
    C.Set<String> withClasses = C.newSet();
    getAllWithList(withClasses, infoBase);
    final ControllerClassMetaInfo me = this;
    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);
        }
    }
}
 
Example 3
Source File: DataPropertyRepository.java    From actframework with Apache License 2.0 5 votes vote down vote up
private void _init() {
    Set<Class> s = C.newSet();
    s.add(BigDecimal.class);
    s.add(BigInteger.class);

    s.add(Date.class);
    s.add(java.sql.Date.class);
    s.add(Calendar.class);
    s.add(DateTime.class);
    s.add(Instant.class);
    s.add(LocalDate.class);
    s.add(LocalDateTime.class);
    s.add(LocalTime.class);

    s.add(Object.class); // use toString() to ouptut

    terminators = s;

    Set<String> s0 = C.newSet();
    for (Class c: s) {
        s0.add(c.getName());
    }

    s0.add("java.time.Instant");
    s0.add("java.time.LocalTime");
    s0.add("java.time.LocalDate");
    s0.add("java.time.LocalDateTime");
    s0.add("org.bson.types.ObjectId");

    extendedTerminators = s0;
}
 
Example 4
Source File: AppByteCodeScannerBase.java    From actframework with Apache License 2.0 5 votes vote down vote up
protected final void addDependencyClass(String className) {
    Set<String> set = dependencyClasses.get(getClass());
    if (null == set) {
        set = C.newSet();
        dependencyClasses.put(getClass(), set);
    }
    set.add(className);
}
 
Example 5
Source File: AppByteCodeScannerBase.java    From actframework with Apache License 2.0 5 votes vote down vote up
protected final void addDependencyClassToScanner(Class<? extends AppByteCodeScanner> scannerClass, String className) {
    Set<String> set = dependencyClasses.get(scannerClass);
    if (null == set) {
        set = C.newSet();
        dependencyClasses.put(scannerClass, set);
    }
    set.add(className);
}
 
Example 6
Source File: AppByteCodeScannerBase.java    From actframework with Apache License 2.0 5 votes vote down vote up
protected final void addDependencyClassToScanner(Class<? extends AppByteCodeScanner> scannerClass, Collection<String> classNames) {
    Set<String> set = dependencyClasses.get(scannerClass);
    if (null == set) {
        set = C.newSet();
        dependencyClasses.put(scannerClass, set);
    }
    set.addAll(classNames);
}
 
Example 7
Source File: SimpleMetricStore.java    From actframework with Apache License 2.0 5 votes vote down vote up
@Override
public List<MetricInfo> timers() {
    Set<MetricInfo> set = C.newSet();
    for (Map.Entry<String, AtomicLong> entry : timers.entrySet()) {
        set.add(new MetricInfo(entry.getKey(), entry.getValue().get(), counters.get(entry.getKey()).get()));
    }
    return C.list(set);
}
 
Example 8
Source File: EventBus.java    From actframework with Apache License 2.0 5 votes vote down vote up
private <T extends EventObject> void callOn(final T event, List<? extends ActEventListener> listeners, boolean async) {
    if (null == listeners) {
        return;
    }
    JobManager jobManager = null;
    if (async) {
        jobManager = app().jobManager();
    }
    Set<ActEventListener> toBeRemoved = C.newSet();
    try {
        for (final ActEventListener l : listeners) {
            if (!async) {
                boolean result = callOn(event, l);
                if (result && once) {
                    toBeRemoved.add(l);
                }
            } else {
                jobManager.now(new Runnable() {
                    @Override
                    public void run() {
                        callOn(event, l);
                    }
                }, event instanceof SysEvent);
            }
        }
    } catch (ConcurrentModificationException e) {
        String eventName;
        if (event instanceof SysEvent) {
            eventName = event.toString();
        } else {
            eventName = event.getClass().getName();
        }
        throw E.unexpected("Concurrent modification issue encountered on handling event: " + eventName);
    }
    if (once && !toBeRemoved.isEmpty()) {
        listeners.removeAll(toBeRemoved);
    }
}
 
Example 9
Source File: OsglSetProvider.java    From java-di with Apache License 2.0 4 votes vote down vote up
@Override
public C.Set<?> get() {
    return C.newSet();
}
 
Example 10
Source File: Contact.java    From actframework with Apache License 2.0 4 votes vote down vote up
public void setEmails(Collection<String> emails) {
    this.emails = C.newSet(emails);
}