Example usage for java.util Collections EMPTY_MAP

List of usage examples for java.util Collections EMPTY_MAP

Introduction

In this page you can find the example usage for java.util Collections EMPTY_MAP.

Prototype

Map EMPTY_MAP

To view the source code for java.util Collections EMPTY_MAP.

Click Source Link

Document

The empty map (immutable).

Usage

From source file:io.melon.peanut.PeanutArrayRequest.java

@Override
public Map<String, String> getHeaders() throws AuthFailureError {
    return api.authRequired ? PeanutAPI.getAuthHeader() : Collections.EMPTY_MAP;
}

From source file:com.milaboratory.test.TestUtil.java

public static synchronized Map<String, String> getProperties() {
    if (envProperties == null) {
        String e = env();/* ww  w.  j  a v  a  2  s.  com*/

        if (e == null)
            envProperties = Collections.EMPTY_MAP;
        else {
            File propsFile = new File(e + "properties.json");

            if (!propsFile.exists())
                envProperties = Collections.EMPTY_MAP;
            else {
                try {
                    envProperties = GlobalObjectMappers.ONE_LINE.readValue(propsFile,
                            new TypeReference<HashMap<String, String>>() {
                            });
                } catch (IOException ex) {
                    envProperties = Collections.EMPTY_MAP;
                }
            }
        }
    }

    return envProperties;
}

From source file:jef.database.query.JpqlExpression.java

public String toSqlAndBindAttribs(final SqlContext context, final DatabaseDialect profile) {
    ///* www . ja va2 s  .c om*/
    st.accept(new SqlFunctionlocalization(profile, null));
    //??
    if (context != null) {
        @SuppressWarnings("unchecked")
        final Map<String, Object> attribs = context.attribute == null ? Collections.EMPTY_MAP
                : context.attribute;
        st.accept(new VisitorAdapter() {
            @Override
            public void visit(JpqlParameter parameter) {
                if (parameter.getName() == null)
                    return;
                Object obj = attribs.get(parameter.getName());
                if (obj == null) {
                    if (!attribs.containsKey(parameter.getName())) {
                        throw new IllegalArgumentException(
                                "You have not set the value of param '" + parameter.getName() + "'");
                    } else {
                        parameter.setResolved("null");
                    }
                } else {
                    if (obj instanceof Number) {
                        parameter.setResolved(String.valueOf(obj));
                    } else {
                        parameter.setResolved("'" + String.valueOf(obj) + "'");
                    }
                }
            }
        });
    }
    //?
    String result;
    if (instance == null) {
        st.accept(new JPQLSelectConvert(profile));
        result = st.toString();
    } else {
        String alias = context == null ? null : context.getAliasOf(instance);
        ColumnAliasApplier convert = new ColumnAliasApplier(alias, profile);
        st.accept(convert);
        result = st.toString();
        convert.undo();
    }
    return result;
}

From source file:fr.gael.dhus.util.functional.collect.SortedMapTest.java

/** Constructor: If comparator param is null, must throw an IllegalArgumentException. */
@Test(expectedExceptions = NullPointerException.class)
@SuppressWarnings("ResultOfObjectAllocationIgnored")
public void nullComparatorTest() {
    new SortedMap(Collections.EMPTY_MAP, null);
}

From source file:se.uu.it.cs.recsys.constraint.builder.CreditDomainBuilder.java

/**
 *
 * @param idSet/*from w w w .  ja  v a  2  s .  co  m*/
 * @return the mapping between credit and the constraint set domain for the
 * input courses ids from planned years
 */
public Map<CourseCredit, SetDomain> getCreditAndIdSetDomainMappingFor(Set<Integer> idSet) {
    if (idSet == null || idSet.isEmpty()) {
        LOGGER.warn("Does not make sense to put null or empty set, right?");
        return Collections.EMPTY_MAP;
    }

    Map<CourseCredit, SetDomain> creditAndDomain = new HashMap<>();

    Map<CourseCredit, Set<Integer>> levelAndIds = getCreditAndIdSetMappingFor(idSet);

    levelAndIds.entrySet().stream().forEach((entry) -> {
        creditAndDomain.put(entry.getKey(), DomainBuilder.createDomain(entry.getValue()));
    });

    return creditAndDomain;
}

From source file:com.evolveum.midpoint.repo.sql.util.HibernateToSqlTranslator.java

/**
 * Do not use in production code! Only for testing purposes only. Used for example during query engine upgrade.
 * Method provides translation from hibernate HQL query to plain SQL string query.
 *
 * @param sessionFactory//from   w w w  .  j ava  2 s.c o m
 * @param hqlQueryText
 * @return SQL string, null if hqlQueryText parameter is empty.
 */
public static String toSql(SessionFactory sessionFactory, String hqlQueryText) {
    Validate.notNull(sessionFactory, "Session factory must not be null.");

    if (StringUtils.isEmpty(hqlQueryText)) {
        return null;
    }

    final QueryTranslatorFactory translatorFactory = new ASTQueryTranslatorFactory();
    final SessionFactoryImplementor factory = (SessionFactoryImplementor) sessionFactory;
    final QueryTranslator translator = translatorFactory.createQueryTranslator(hqlQueryText, hqlQueryText,
            Collections.EMPTY_MAP, factory, null);
    translator.compile(Collections.EMPTY_MAP, false);
    return translator.getSQLString();
}

From source file:org.cosmo.common.template.BindingSrc.java

public Map<String, Binding> callBindings() {
    return _caller == null ? Collections.EMPTY_MAP : _caller._callBindings;
}

From source file:org.ambraproject.action.BaseActionSupport.java

/**
 * This overrides the deprecated super inplementation and returns an empty implementation as we
 * want to avoid JSON serializing the deprecated implementation when it tries to serialize
 * an Action when the result type is ajaxJSON.
 *
 * @return a empty map/*w ww  .j  a  va2s  . c  om*/
 */
@Override
public Map getErrors() {
    return Collections.EMPTY_MAP;
}

From source file:com.feedzai.fos.impl.weka.WekaManagerTest.java

private ModelConfig setupModelConfig() {
    List<Attribute> attributes = new ArrayList<Attribute>();
    attributes.add(new NumericAttribute("firstNumeric"));
    attributes.add(new NumericAttribute("secondNumeric"));

    ModelConfig mc = new ModelConfig(new ArrayList<Attribute>() {
        {/*from  www . j  a  va 2  s  .c  o m*/
            add(new NumericAttribute("field"));
        }
    }, Collections.EMPTY_MAP);

    return mc;
}

From source file:org.apache.tomee.spring.ExportEjbsToSpringExtension.java

public Map<String, EJB> getEjbBindings(BeanContext deployment) {
    if (!deployment.getComponentType().isSession())
        return Collections.EMPTY_MAP;

    final Map<String, EJB> bindings = new TreeMap<String, EJB>();

    if (deployment.isLocalbean()) {
        bindings.put(deployment.getDeploymentID() + "",
                new EJB(deployment, InterfaceType.LOCALBEAN, deployment.getBeanClass()));
    }/*  w  w w  . j  a  v a 2  s . c  o m*/

    for (Class businessLocal : deployment.getBusinessLocalInterfaces()) {
        bindings.put(deployment.getDeploymentID() + "!" + businessLocal.getName(),
                new EJB(deployment, InterfaceType.BUSINESS_LOCAL, businessLocal));
    }

    for (Class businessRemote : deployment.getBusinessRemoteInterfaces()) {
        bindings.put(deployment.getDeploymentID() + "!" + businessRemote.getName(),
                new EJB(deployment, InterfaceType.BUSINESS_REMOTE, businessRemote));
    }

    return bindings;
}