Example usage for com.google.common.collect ImmutableMultiset of

List of usage examples for com.google.common.collect ImmutableMultiset of

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableMultiset of.

Prototype

@SuppressWarnings("unchecked") 
public static <E> ImmutableMultiset<E> of(E e1, E e2, E e3) 

Source Link

Document

Returns an immutable multiset containing the given elements, in the "grouped iteration order" described in the class documentation.

Usage

From source file:org.joda.beans.ser.SerTestHelper.java

@SuppressWarnings("unchecked")
public static ImmAddress testImmAddress() {
    Map<String, List<String>> map = new HashMap<String, List<String>>();
    map.put("A", Arrays.asList("B", "b"));
    Map<String, List<Integer>> map2 = new HashMap<String, List<Integer>>();
    map2.put("A", Arrays.asList(3, 2, 1));
    Map<String, List<List<Integer>>> map3 = new HashMap<String, List<List<Integer>>>();
    map3.put("A", Arrays.asList(Arrays.asList(3, 2, 1)));
    Map<ImmPerson, Map<String, ImmPerson>> map4 = new HashMap<ImmPerson, Map<String, ImmPerson>>();
    Map<String, List<List<Object>>> map5 = new HashMap<String, List<List<Object>>>();
    PrimitiveBean primitives = new PrimitiveBean();
    primitives.setValueLong(1L);/*from   w  ww . j a v a 2s. c  om*/
    primitives.setValueInt(2);
    primitives.setValueShort((short) 3);
    primitives.setValueByte((byte) 4);
    primitives.setValueDouble(5.0d);
    primitives.setValueFloat(6.0f);
    primitives.setValueChar('7');
    primitives.setValueBoolean(true);
    List<Object> objects1 = Arrays.<Object>asList(Currency.getInstance("GBP"),
            TimeZone.getTimeZone("Europe/London"));
    List<Object> objects2 = Arrays.<Object>asList(Locale.CANADA_FRENCH, Long.valueOf(2), primitives);
    map5.put("A", Arrays.asList(objects1));
    map5.put("B", Arrays.asList(objects2));
    Map<String, Object> map6 = new HashMap<String, Object>();
    map6.put("A", "Abba");
    map6.put("B", ImmutableSet.of("a", "b"));
    map6.put("C", ImmutableSet.copyOf(objects2));
    map6.put("D", ImmutableMap.of("d", 1, "e", 2));
    ImmPerson person = ImmPerson.builder().forename("Etienne").middleNames("K", "T").surname("Colebourne")
            .addressList(Arrays.asList(new Address())).codeCounts(ImmutableMultiset.of("A", "A", "B")).build();
    ImmPerson child = ImmPerson.builder().forename("Etiennette").surname("Colebourne").build();
    ImmPerson child2 = ImmPerson.builder().forename("Kylie").surname("Colebourne").build();
    ImmAddress childAddress = ImmAddress.builder().owner(child).number(185).street("Park Street").city("London")
            .risk(RiskLevel.LOW).riskLevel(RiskLevel.HIGH)
            .riskLevels(EnumSet.of(RiskLevel.LOW, RiskLevel.MEDIUM)).object1(RiskLevel.MEDIUM)
            .object2(RiskPerception.LOW).data(new byte[] { 64, 65, 66 }).build();
    map4.put(child, ImmutableMap.of("sibling", child2));
    HashBasedTable<Integer, Integer, ImmPerson> table = HashBasedTable.create();
    table.put(1, 1, person);
    table.put(1, 2, child);
    table.put(2, 1, child2);
    SparseGrid<ImmPerson> sparseGrid = SparseGrid.create(5, 5);
    sparseGrid.put(1, 1, child2);
    DenseGrid<ImmPerson> denseGrid = DenseGrid.create(2, 3);
    denseGrid.put(0, 0, child);
    denseGrid.put(1, 1, child2);
    ImmAddress address = ImmAddress.builder().owner(person).number(185).street("Park Street")
            .city("London & Capital of the World <!>\n").abstractNumber(Short.valueOf((short) 89))
            .array2d(new String[][] { { "a" }, {}, { "b", "c" } }).object1(ImmutableList.of("a", "b", "c"))
            .object2(ImmutableMap.of("d", 1, Currency.getInstance("GBP"), 2))
            .serializable(ImmutableList.of("a", "b", "c")).objectInMap(map6).listInMap(map)
            .listNumericInMap(map2).listInListInMap(map3).objectListInListInMap(map5).mapInMap(map4)
            .simpleTable(ImmutableTable.of(1, 1, "Hello")).compoundTable(table).sparseGrid(sparseGrid)
            .denseGrid(denseGrid).beanBeanMap(ImmutableMap.of(child, childAddress)).build();
    return address;
}