Search in sources :

Example 81 with LinkedHashSet

use of java.util.LinkedHashSet in project intellij-community by JetBrains.

the class FormNode method getChildren.

private static Collection<BasePsiNode<? extends PsiElement>> getChildren(final Project project, final Form form, final ViewSettings settings) {
    final Set<BasePsiNode<? extends PsiElement>> children = new LinkedHashSet<>();
    children.add(new ClassTreeNode(project, form.getClassToBind(), settings));
    for (PsiFile formBoundToClass : form.getFormFiles()) {
        children.add(new PsiFileNode(project, formBoundToClass, settings));
    }
    return children;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) PsiFileNode(com.intellij.ide.projectView.impl.nodes.PsiFileNode) PsiFile(com.intellij.psi.PsiFile) BasePsiNode(com.intellij.ide.projectView.impl.nodes.BasePsiNode) PsiElement(com.intellij.psi.PsiElement) ClassTreeNode(com.intellij.ide.projectView.impl.nodes.ClassTreeNode)

Example 82 with LinkedHashSet

use of java.util.LinkedHashSet in project jackson-databind by FasterXML.

the class JsonValueSerializer method _acceptJsonFormatVisitorForEnum.

/**
     * Overridable helper method used for special case handling of schema information for
     * Enums.
     * 
     * @return True if method handled callbacks; false if not; in latter case caller will
     *   send default callbacks
     *
     * @since 2.6
     */
protected boolean _acceptJsonFormatVisitorForEnum(JsonFormatVisitorWrapper visitor, JavaType typeHint, Class<?> enumType) throws JsonMappingException {
    // Copied from EnumSerializer#acceptJsonFormatVisitor
    JsonStringFormatVisitor stringVisitor = visitor.expectStringFormat(typeHint);
    if (stringVisitor != null) {
        Set<String> enums = new LinkedHashSet<String>();
        for (Object en : enumType.getEnumConstants()) {
            try {
                // 21-Apr-2016, tatu: This is convoluted to the max, but essentially we
                //   call `@JsonValue`-annotated accessor method on all Enum members,
                //   so it all "works out". To some degree.
                enums.add(String.valueOf(_accessor.getValue(en)));
            } catch (Exception e) {
                Throwable t = e;
                while (t instanceof InvocationTargetException && t.getCause() != null) {
                    t = t.getCause();
                }
                ClassUtil.throwIfError(t);
                throw JsonMappingException.wrapWithPath(t, en, _accessor.getName() + "()");
            }
        }
        stringVisitor.enumTypes(enums);
    }
    return true;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) JsonStringFormatVisitor(com.fasterxml.jackson.databind.jsonFormatVisitors.JsonStringFormatVisitor) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 83 with LinkedHashSet

use of java.util.LinkedHashSet in project Activiti by Activiti.

the class MBeanInfoAssembler method getMBeanInfo.

public ModelMBeanInfo getMBeanInfo(Object defaultManagedBean, Object customManagedBean, String objectName) throws JMException {
    if ((defaultManagedBean == null && customManagedBean == null) || objectName == null)
        return null;
    // skip proxy classes
    if (defaultManagedBean != null && Proxy.isProxyClass(defaultManagedBean.getClass())) {
        LOG.trace("Skip creating ModelMBeanInfo due proxy class {}", defaultManagedBean.getClass());
        return null;
    }
    // maps and lists to contain information about attributes and operations
    Map<String, ManagedAttributeInfo> attributes = new LinkedHashMap<String, ManagedAttributeInfo>();
    Set<ManagedOperationInfo> operations = new LinkedHashSet<ManagedOperationInfo>();
    Set<ModelMBeanAttributeInfo> mBeanAttributes = new LinkedHashSet<ModelMBeanAttributeInfo>();
    Set<ModelMBeanOperationInfo> mBeanOperations = new LinkedHashSet<ModelMBeanOperationInfo>();
    Set<ModelMBeanNotificationInfo> mBeanNotifications = new LinkedHashSet<ModelMBeanNotificationInfo>();
    // extract details from default managed bean
    if (defaultManagedBean != null) {
        extractAttributesAndOperations(defaultManagedBean.getClass(), attributes, operations);
        extractMbeanAttributes(defaultManagedBean, attributes, mBeanAttributes, mBeanOperations);
        extractMbeanOperations(defaultManagedBean, operations, mBeanOperations);
        extractMbeanNotifications(defaultManagedBean, mBeanNotifications);
    }
    // extract details from custom managed bean
    if (customManagedBean != null) {
        extractAttributesAndOperations(customManagedBean.getClass(), attributes, operations);
        extractMbeanAttributes(customManagedBean, attributes, mBeanAttributes, mBeanOperations);
        extractMbeanOperations(customManagedBean, operations, mBeanOperations);
        extractMbeanNotifications(customManagedBean, mBeanNotifications);
    }
    // create the ModelMBeanInfo
    String name = getName(customManagedBean != null ? customManagedBean : defaultManagedBean, objectName);
    String description = getDescription(customManagedBean != null ? customManagedBean : defaultManagedBean, objectName);
    ModelMBeanAttributeInfo[] arrayAttributes = mBeanAttributes.toArray(new ModelMBeanAttributeInfo[mBeanAttributes.size()]);
    ModelMBeanOperationInfo[] arrayOperations = mBeanOperations.toArray(new ModelMBeanOperationInfo[mBeanOperations.size()]);
    ModelMBeanNotificationInfo[] arrayNotifications = mBeanNotifications.toArray(new ModelMBeanNotificationInfo[mBeanNotifications.size()]);
    ModelMBeanInfo info = new ModelMBeanInfoSupport(name, description, arrayAttributes, null, arrayOperations, arrayNotifications);
    LOG.trace("Created ModelMBeanInfo {}", info);
    return info;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ModelMBeanOperationInfo(javax.management.modelmbean.ModelMBeanOperationInfo) ModelMBeanNotificationInfo(javax.management.modelmbean.ModelMBeanNotificationInfo) ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) LinkedHashMap(java.util.LinkedHashMap) ModelMBeanAttributeInfo(javax.management.modelmbean.ModelMBeanAttributeInfo) ModelMBeanInfoSupport(javax.management.modelmbean.ModelMBeanInfoSupport)

Example 84 with LinkedHashSet

use of java.util.LinkedHashSet in project opennms by OpenNMS.

the class MetadataFieldReader method getMetadataFields.

public Set<MetadataField> getMetadataFields() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
    final Set<MetadataField> fields = new LinkedHashSet<>();
    if (m_propertyFile.exists() && m_propertyFile.canRead()) {
        final Properties props = new LinkedProperties();
        Reader r = null;
        try {
            r = new FileReader(m_propertyFile);
            props.load(r);
            final Set<String> names = new LinkedHashSet<>();
            for (final Entry<Object, Object> entry : props.entrySet()) {
                LOG.debug("{}={}", entry.getKey(), entry.getValue());
                if (entry.getKey() != null) {
                    final String key = entry.getKey().toString().trim();
                    if (key.endsWith(".description")) {
                        names.add(key.replaceAll("\\.description$", ""));
                    } else if (key.endsWith(".validator")) {
                        names.add(key.replaceAll("\\.validator$", ""));
                    } else if (key.endsWith(".required")) {
                        names.add(key.replaceAll("\\.required$", ""));
                    } else {
                        LOG.debug("Unknown metadata entry: {}", key);
                    }
                }
            }
            for (final String name : names) {
                final String description = props.getProperty(name + ".description");
                final String validatorClass = props.getProperty(name + ".validator");
                final String requiredString = props.getProperty(name + ".required");
                @SuppressWarnings("unchecked") final Class<Validator> validator = validatorClass == null ? null : (Class<Validator>) Class.forName(validatorClass);
                final Boolean required = Boolean.valueOf(requiredString);
                fields.add(new MetadataField(name, description, validator == null ? null : validator.newInstance(), required));
            }
        } catch (final IOException e) {
            LOG.warn("Failed to get metadata fields.", e);
        } finally {
            IOUtils.closeQuietly(r);
        }
    }
    return fields;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Reader(java.io.Reader) FileReader(java.io.FileReader) IOException(java.io.IOException) Properties(java.util.Properties) FileReader(java.io.FileReader) Validator(org.opennms.netmgt.poller.remote.metadata.MetadataField.Validator)

Example 85 with LinkedHashSet

use of java.util.LinkedHashSet in project Etar-Calendar by Etar-Group.

the class GlobalDismissManager method dismissGlobally.

/**
     * Globally dismiss notifications that are backed by the same events.
     *
     * @param context application context
     * @param alarmIds Unique identifiers for events that have been dismissed by the user.
     * @return true if notification_sender_id is available
     */
public static void dismissGlobally(final Context context, final List<AlarmId> alarmIds) {
    final String senderId = context.getResources().getString(R.string.notification_sender_id);
    if ("".equals(senderId)) {
        Log.i(TAG, "no sender configured");
        return;
    }
    Set<Long> eventIds = new HashSet<Long>(alarmIds.size());
    for (AlarmId alarmId : alarmIds) {
        eventIds.add(alarmId.mEventId);
    }
    // find the mapping between calendars and events
    Map<Long, Long> eventsToCalendars = lookupEventToCalendarMap(context, eventIds);
    if (eventsToCalendars.isEmpty()) {
        Log.d(TAG, "found no calendars for events");
        return;
    }
    Set<Long> calendars = new LinkedHashSet<Long>();
    calendars.addAll(eventsToCalendars.values());
    // find the accounts associated with those calendars
    Map<Long, Pair<String, String>> calendarsToAccounts = lookupCalendarToAccountMap(context, calendars);
    if (calendarsToAccounts.isEmpty()) {
        Log.d(TAG, "found no accounts for calendars");
        return;
    }
    // TODO group by account to reduce queries
    Map<String, String> syncIdToAccount = new HashMap<String, String>();
    Map<Long, String> eventIdToSyncId = new HashMap<Long, String>();
    ContentResolver resolver = context.getContentResolver();
    for (Long eventId : eventsToCalendars.keySet()) {
        Long calendar = eventsToCalendars.get(eventId);
        Pair<String, String> account = calendarsToAccounts.get(calendar);
        if (GOOGLE_ACCOUNT_TYPE.equals(account.first)) {
            Uri uri = asSync(Events.CONTENT_URI, account.first, account.second);
            Cursor cursor = resolver.query(uri, EVENT_SYNC_PROJECTION, Events._ID + " = " + eventId, null, null);
            try {
                cursor.moveToPosition(-1);
                int sync_id_idx = cursor.getColumnIndex(Events._SYNC_ID);
                if (sync_id_idx != -1) {
                    while (cursor.moveToNext()) {
                        String syncId = cursor.getString(sync_id_idx);
                        syncIdToAccount.put(syncId, account.second);
                        eventIdToSyncId.put(eventId, syncId);
                    }
                }
            } finally {
                cursor.close();
            }
        }
    }
    if (syncIdToAccount.isEmpty()) {
        Log.d(TAG, "found no syncIds for events");
        return;
    }
    // TODO group by account to reduce packets
    CloudNotificationBackplane cnb = ExtensionsFactory.getCloudNotificationBackplane();
    if (cnb.open(context)) {
        for (AlarmId alarmId : alarmIds) {
            String syncId = eventIdToSyncId.get(alarmId.mEventId);
            String account = syncIdToAccount.get(syncId);
            Bundle data = new Bundle();
            data.putString(SYNC_ID, syncId);
            data.putString(START_TIME, Long.toString(alarmId.mStart));
            data.putString(ACCOUNT_NAME, account);
            try {
                cnb.send(account, syncId + ":" + alarmId.mStart, data);
            } catch (IOException e) {
            // TODO save a note to try again later
            }
        }
        cnb.close();
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) HashMap(java.util.HashMap) CloudNotificationBackplane(com.android.calendar.CloudNotificationBackplane) Bundle(android.os.Bundle) IOException(java.io.IOException) Cursor(android.database.Cursor) Uri(android.net.Uri) ContentResolver(android.content.ContentResolver) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Pair(android.util.Pair)

Aggregations

LinkedHashSet (java.util.LinkedHashSet)3111 ArrayList (java.util.ArrayList)632 Set (java.util.Set)410 HashSet (java.util.HashSet)334 HashMap (java.util.HashMap)312 Map (java.util.Map)284 List (java.util.List)269 File (java.io.File)266 LinkedHashMap (java.util.LinkedHashMap)257 IOException (java.io.IOException)240 Test (org.junit.Test)239 LinkedList (java.util.LinkedList)139 Collection (java.util.Collection)103 URL (java.net.URL)83 ProcessResult (org.asqatasun.entity.audit.ProcessResult)76 Iterator (java.util.Iterator)73 SourceCodeRemark (org.asqatasun.entity.audit.SourceCodeRemark)73 TreeMap (java.util.TreeMap)70 TreeSet (java.util.TreeSet)70 Collectors (java.util.stream.Collectors)69