org.apache.commons.collections4.map.ListOrderedMap Java Examples
The following examples show how to use
org.apache.commons.collections4.map.ListOrderedMap.
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: ActionFetchWithJob.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
ActionResult<JsonElement> execute(EffectivePerson effectivePerson, String job, JsonElement jsonElement) throws Exception { ActionResult<JsonElement> result = new ActionResult<>(); try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { Wi wi = this.convertToWrapIn(jsonElement, Wi.class); Business business = new Business(emc); if ((!this.manager(business, effectivePerson)) && (emc.countEqual(Review.class, Review.person_FIELDNAME, effectivePerson.getDistinguishedName()) == 0) && (!this.applicationControl(business, effectivePerson, job))) { throw new ExceptionJobAccessDenied(effectivePerson.getName(), job); } Map<String, Object> map = new ListOrderedMap<>(); for (String path : wi.getPathList()) { map.put(path, this.getData(business, job, StringUtils.split(path, "."))); } result.setData(gson.toJsonTree(map)); return result; } }
Example #2
Source File: OrderedMapUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void givenAListOrderedMap_whenElementRemoved_thenSizeDecrease() { ListOrderedMap<String, Integer> lomap = (ListOrderedMap<String, Integer>) this.runnersListOrderedMap; Integer johnAge = lomap.remove("John");// by object assertEquals(johnAge, new Integer(36)); assertEquals(lomap.size(), RUNNERS_COUNT - 1); Integer emilyAge = lomap.remove(0);// by index assertEquals(emilyAge, new Integer(37)); assertEquals(lomap.size(), RUNNERS_COUNT - 2); }
Example #3
Source File: ModifiableMessageStructure.java From sailfish-core with Apache License 2.0 | 5 votes |
private ModifiableMessageStructure(String id, String name, String namespace, String description, Map<String, ModifiableFieldStructure> fields, Map<String, ModifiableAttributeStructure> attributes, boolean isRequired, boolean isCollection, ModifiableMessageStructure reference) { super(id, name, namespace, description, attributes, null, null, isRequired, isCollection, false, null); this.fields = fields != null ? ListOrderedMap.listOrderedMap(fields) : new ListOrderedMap<>(); this.reference = reference; }
Example #4
Source File: OrderedMapUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void givenAListOrderedMap_whenSearchByIndexIsUsed_thenMatchesConstantArray() { ListOrderedMap<String, Integer> lomap = (ListOrderedMap<String, Integer>) this.runnersListOrderedMap; for (int i = 0; i < RUNNERS_COUNT; i++) { // accessed by index: String name = lomap.get(i); assertEquals(name, this.names[i]); // index of key concides with position in array assertEquals(lomap.indexOf(this.names[i]), i); } }
Example #5
Source File: KryoTranscoderTests.java From springboot-shiro-cas-mybatis with MIT License | 5 votes |
@Test public void verifyEncodeDecodeTGTWithListOrderedMap() throws Exception { final Credential userPassCredential = new UsernamePasswordCredential(USERNAME, PASSWORD); @SuppressWarnings("unchecked") final TicketGrantingTicket expectedTGT = new MockTicketGrantingTicket(TGT_ID, userPassCredential, ListOrderedMap.listOrderedMap(this.principalAttributes)); expectedTGT.grantServiceTicket(ST_ID, null, null, false); assertEquals(expectedTGT, transcoder.decode(transcoder.encode(expectedTGT))); }
Example #6
Source File: OrderedMapUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void givenAListOrderedMap_whenConvertedToList_thenMatchesKeySet() { ListOrderedMap<String, Integer> lomap = (ListOrderedMap<String, Integer>) this.runnersListOrderedMap; List<String> listKeys = new ArrayList<>(); listKeys.addAll(this.runnersListOrderedMap.keySet()); List<String> lomapList = lomap.asList(); assertEquals(listKeys, lomapList); }
Example #7
Source File: TransactionUtil.java From scipio-erp with Apache License 2.0 | 5 votes |
/** * Remove the stamp from stack (when resuming) */ private static void popTransactionStartStamp() { ListOrderedMap<Transaction, Timestamp> map = (ListOrderedMap<Transaction, Timestamp>) suspendedTxStartStamps.get(); if (map.size() > 0) { transactionStartStamp.set((Timestamp) map.remove(map.lastKey())); } else { Debug.logError("Error in transaction handling - no saved start stamp found - using NOW.", module); transactionStartStamp.set(UtilDateTime.nowTimestamp()); } }
Example #8
Source File: SectionedRecyclerViewAdapter.java From SectionedRecyclerViewAdapter with MIT License | 5 votes |
public SectionedRecyclerViewAdapter() { super(); sections = new ListOrderedMap<>(); sectionViewTypeNumbers = new LinkedHashMap<>(); sectionAdapters = new HashMap<>(); }
Example #9
Source File: OrderedMapUnitTest.java From tutorials with MIT License | 5 votes |
@Before public void createRunners() { // First implementation: ListOrderedMap this.runnersListOrderedMap = new ListOrderedMap<>(); this.loadOrderedMapOfRunners(this.runnersListOrderedMap); // Second implementation: LinkedMap this.runnersLinkedMap = new LinkedMap<>(); this.loadOrderedMapOfRunners(this.runnersLinkedMap); }
Example #10
Source File: SectionPositionIdentifierEmptyAdapterTest.java From SectionedRecyclerViewAdapter with MIT License | 5 votes |
@Before public void setUp() { MockitoAnnotations.initMocks(this); when(sectionedAdapter.getSections()).thenReturn(new ListOrderedMap<>()); cut = new SectionAdapter(sectionedAdapter, section); }
Example #11
Source File: Scenario4.java From SectionedRecyclerViewAdapter with MIT License | 5 votes |
public Scenario4() { sections = new ListOrderedMap<>(); loadingSection = mock(Section.class); when(loadingSection.isVisible()).thenReturn(true); when(loadingSection.hasHeader()).thenReturn(false); when(loadingSection.hasFooter()).thenReturn(false); when(loadingSection.getSectionItemsTotal()).thenReturn(1); when(loadingSection.getState()).thenReturn(Section.State.LOADING); sections.put(LOADING_SECTION_TAG, loadingSection); final Section section2 = mock(Section.class); when(section2.isVisible()).thenReturn(false); when(section2.getSectionItemsTotal()).thenReturn(10); when(section2.getState()).thenReturn(Section.State.LOADED); sections.put(UUID.randomUUID().toString(), section2); failedSection = mock(Section.class); when(failedSection.isVisible()).thenReturn(true); when(failedSection.hasHeader()).thenReturn(true); when(failedSection.hasFooter()).thenReturn(true); when(failedSection.getContentItemsTotal()).thenReturn(0); when(failedSection.getSectionItemsTotal()).thenReturn(3); when(failedSection.getState()).thenReturn(Section.State.FAILED); sections.put(FAILED_SECTION_TAG, failedSection); emptySection = mock(Section.class); when(emptySection.isVisible()).thenReturn(true); when(emptySection.hasHeader()).thenReturn(true); when(emptySection.hasFooter()).thenReturn(true); when(emptySection.getContentItemsTotal()).thenReturn(0); when(emptySection.getSectionItemsTotal()).thenReturn(3); when(emptySection.getState()).thenReturn(Section.State.EMPTY); sections.put(EMPTY_SECTION_TAG, emptySection); }
Example #12
Source File: Scenario1.java From SectionedRecyclerViewAdapter with MIT License | 5 votes |
public Scenario1() { section = mock(Section.class); sections = new ListOrderedMap<>(); final Section section1 = mock(Section.class); when(section1.isVisible()).thenReturn(true); when(section1.hasHeader()).thenReturn(true); when(section1.hasFooter()).thenReturn(true); when(section1.getSectionItemsTotal()).thenReturn(12); when(section1.getState()).thenReturn(Section.State.LOADED); sections.put(UUID.randomUUID().toString(), section1); final Section section2 = mock(Section.class); when(section2.isVisible()).thenReturn(false); when(section2.getSectionItemsTotal()).thenReturn(10); when(section2.getState()).thenReturn(Section.State.LOADED); sections.put(UUID.randomUUID().toString(), section2); when(section.isVisible()).thenReturn(true); when(section.hasHeader()).thenReturn(true); when(section.hasFooter()).thenReturn(true); when(section.getContentItemsTotal()).thenReturn(10); when(section.getSectionItemsTotal()).thenReturn(12); when(section.getState()).thenReturn(Section.State.LOADED); sections.put(SECTION_TAG, section); final Section section4 = mock(Section.class); when(section4.isVisible()).thenReturn(false); when(section4.hasHeader()).thenReturn(true); when(section4.hasFooter()).thenReturn(true); when(section4.getSectionItemsTotal()).thenReturn(12); when(section4.getState()).thenReturn(Section.State.LOADED); sections.put(UUID.randomUUID().toString(), section4); }
Example #13
Source File: Scenario3.java From SectionedRecyclerViewAdapter with MIT License | 5 votes |
public Scenario3() { section = mock(Section.class); sections = new ListOrderedMap<>(); final Section section1 = mock(Section.class); when(section1.isVisible()).thenReturn(true); when(section1.hasHeader()).thenReturn(true); when(section1.hasFooter()).thenReturn(true); when(section1.getSectionItemsTotal()).thenReturn(12); when(section1.getState()).thenReturn(Section.State.LOADED); sections.put(UUID.randomUUID().toString(), section1); final Section section2 = mock(Section.class); when(section2.isVisible()).thenReturn(false); when(section2.getSectionItemsTotal()).thenReturn(10); when(section2.getState()).thenReturn(Section.State.LOADED); sections.put(UUID.randomUUID().toString(), section2); when(section.isVisible()).thenReturn(true); when(section.hasHeader()).thenReturn(true); when(section.hasFooter()).thenReturn(true); when(section.getContentItemsTotal()).thenReturn(0); when(section.getSectionItemsTotal()).thenReturn(2); when(section.getState()).thenReturn(Section.State.LOADED); sections.put(SECTION_TAG, section); final Section section4 = mock(Section.class); when(section4.isVisible()).thenReturn(false); when(section4.hasHeader()).thenReturn(true); when(section4.hasFooter()).thenReturn(true); when(section4.getSectionItemsTotal()).thenReturn(12); when(section4.getState()).thenReturn(Section.State.LOADED); sections.put(UUID.randomUUID().toString(), section4); }
Example #14
Source File: Scenario2.java From SectionedRecyclerViewAdapter with MIT License | 5 votes |
public Scenario2() { section = mock(Section.class); sections = new ListOrderedMap<>(); final Section section1 = mock(Section.class); when(section1.isVisible()).thenReturn(true); when(section1.hasHeader()).thenReturn(true); when(section1.hasFooter()).thenReturn(true); when(section1.getSectionItemsTotal()).thenReturn(12); when(section1.getState()).thenReturn(Section.State.LOADED); sections.put(UUID.randomUUID().toString(), section1); final Section section2 = mock(Section.class); when(section2.isVisible()).thenReturn(false); when(section2.getSectionItemsTotal()).thenReturn(10); when(section2.getState()).thenReturn(Section.State.LOADED); sections.put(UUID.randomUUID().toString(), section2); when(section.isVisible()).thenReturn(true); when(section.hasHeader()).thenReturn(true); when(section.hasFooter()).thenReturn(true); when(section.getContentItemsTotal()).thenReturn(1); when(section.getSectionItemsTotal()).thenReturn(3); when(section.getState()).thenReturn(Section.State.LOADED); sections.put(SECTION_TAG, section); final Section section4 = mock(Section.class); when(section4.isVisible()).thenReturn(false); when(section4.hasHeader()).thenReturn(true); when(section4.hasFooter()).thenReturn(true); when(section4.getSectionItemsTotal()).thenReturn(12); when(section4.getState()).thenReturn(Section.State.LOADED); sections.put(UUID.randomUUID().toString(), section4); }
Example #15
Source File: Scenario4.java From SectionedRecyclerViewAdapter with MIT License | 4 votes |
public ListOrderedMap<String, Section> getSections() { return sections; }
Example #16
Source File: Scenario3.java From SectionedRecyclerViewAdapter with MIT License | 4 votes |
@Override public ListOrderedMap<String, Section> getSections() { return sections; }
Example #17
Source File: Scenario2.java From SectionedRecyclerViewAdapter with MIT License | 4 votes |
@Override public ListOrderedMap<String, Section> getSections() { return sections; }
Example #18
Source File: Scenario1.java From SectionedRecyclerViewAdapter with MIT License | 4 votes |
@Override public ListOrderedMap<String, Section> getSections() { return sections; }
Example #19
Source File: DictionaryEditorModel.java From sailfish-core with Apache License 2.0 | 4 votes |
private void switchFields(boolean down) { if (selectedLeftField == null || selectedLeftField.getField().isMessage()) { return; } TreeModel<FieldEditorModel> parent = selectedLeftField.getTreeModel().getParent(); List<TreeModel<FieldEditorModel>> childs = parent.getChildren(); int curIndex = -1; for (int i = 0; i < childs.size(); i++) { TreeModel<FieldEditorModel> model = childs.get(i); if(model.getData().equals(selectedLeftField)) { curIndex = i; break; } } if ((down && curIndex != -1 && curIndex != childs.size() - 1) || (!down && curIndex > 0)) { FieldEditorModel msgModel = parent.getData(); ListOrderedMap<String, ModifiableFieldStructure> fields; if (msgModel.getField().isMessage()) { fields = ((ModifiableMessageStructure)msgModel.getField()).getImplFields(); } else { TreeModel<FieldEditorModel> refNode = getTreeModelMessageById(msgModel.getField().getImplReference().getId()); switchTreeModels(refNode, curIndex, down); if (!refNode.getData().isCollapsed()) { RequestContext.getCurrentInstance().update("tree:" + refNode.getData().getIndex() + ":inside"); } fields = ((ModifiableMessageStructure)msgModel.getField().getReference()).getImplFields(); } // Switch nodes in sub messages List<TreeModel<FieldEditorModel>> lor = new ArrayList<>(); createListOfReferences(lor, msgModel.getTreeModel().getData().getField().getId(), tree); for (TreeModel<FieldEditorModel> ref : lor) { if (ref != parent) { switchTreeModels(ref, curIndex, down); if (!ref.getData().isCollapsed()) { RequestContext.getCurrentInstance().update("tree:" + ref.getData().getIndex() + ":inside"); } } } int index = fields.valueList().indexOf(selectedLeftField.getField()); ModifiableFieldStructure toMove = fields.remove(index); fields.put(index + (down ? 1 : -1), toMove.getName(), toMove); switchTreeModels(parent, curIndex, down); } }
Example #20
Source File: TransactionUtil.java From scipio-erp with Apache License 2.0 | 4 votes |
@Override public Map<Transaction, Timestamp> initialValue() { return new ListOrderedMap<>(); }
Example #21
Source File: ModifiableMessageStructure.java From sailfish-core with Apache License 2.0 | 4 votes |
public ListOrderedMap<String, ModifiableFieldStructure> getImplFields() { return fields; }
Example #22
Source File: ModifiableMessageStructure.java From sailfish-core with Apache License 2.0 | 4 votes |
public ModifiableMessageStructure() { this.fields = new ListOrderedMap<>(); }
Example #23
Source File: TestScenario.java From SectionedRecyclerViewAdapter with MIT License | 2 votes |
/** * Map of sections that should be available in the adapter * * @return map of sections */ ListOrderedMap<String, Section> getSections();
Example #24
Source File: SectionedRecyclerViewAdapter.java From SectionedRecyclerViewAdapter with MIT License | 2 votes |
/** * Return a copy of the map with all sections of this adapter. * * @return a copy of the map with all sections */ @NonNull public Map<String, Section> getCopyOfSectionsMap() { return ListOrderedMap.listOrderedMap(sections); }
Example #25
Source File: SectionedRecyclerViewAdapter.java From SectionedRecyclerViewAdapter with MIT License | 2 votes |
/** * Return the map with all sections. * Should only be used by the library itself. * * @return map with all sections */ @SuppressWarnings("PMD.DefaultPackage") /* default */ ListOrderedMap<String, Section> getSections() { return sections; }