Java Code Examples for java.util.ArrayList.removeIf()

The following are Jave code examples for showing how to use removeIf() of the java.util.ArrayList class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: dooo   File: WashMap.java   Source Code and License Vote up 6 votes
public static void main(String[] args) {
    ArrayList<String> list = new ArrayList<>(Arrays.asList("I", "love", "you", "too"));

    list.removeIf(new Predicate<String>() {
        @Override
        public boolean test(String s) {
            if (s.length() < 2) {

                return true;
            }
            return false;
        }
    });
    list.removeIf(l -> l.length() < 4);
    System.out.println(JSON.toJSONString(list));
    Date date = new Date();

    ConcurrentHashMap concurrentHashMap = new ConcurrentHashMap<>();
    concurrentHashMap.put("ds", 1);
    concurrentHashMap.computeIfAbsent("fdfd", k -> k.toString());
    System.out.println(JSON.toJSONString(concurrentHashMap));
    HashMap hashMap = new HashMap<>();
    hashMap.put("fd1", 1);
    hashMap.put("fd2", 1);
    hashMap.put("fd3", 1);
    hashMap.put("fd4", "fd");
    hashMap.put("fd5", 1);
    hashMap.entrySet().stream().forEach(hash -> {
        System.out.println(hash.toString());
    });
}
 
Example 2
Project: customstuff4   File: TransferInfo.java   Source Code and License Vote up 5 votes
@Override
public List<Slot> getRecipeSlots(ContainerGui container)
{
    ArrayList<Slot> slots = Lists.newArrayList(container.getSlotsForSource(moduleName));
    slots.removeIf(slot -> slot.getSlotIndex() >= inputSlots);
    return slots;
}
 
Example 3
Project: trvlr-backend   File: PrivateChatRoomController.java   Source Code and License Vote up 5 votes
/**
 * Get all private chat rooms of a traveler
 *
 * @param travelerId int
 * @return List<ChatRoom>
 */
@RequestMapping(path = "/api/private-chats/list/{travelerId}", method = RequestMethod.GET)
public List<ChatRoom> getPrivateChatsByTraveler(@PathVariable int travelerId) {
	ArrayList<ChatRoom> rooms = chatRoomRepository.getByTravelerId(travelerId);
	rooms.removeIf(c -> !c.isPrivate());
	return rooms;
}
 
Example 4
Project: trvlr-backend   File: PublicChatRoomController.java   Source Code and License Vote up 5 votes
/**
 * Get all publich chat rooms of a traveler
 *
 * @param travelerId int
 * @return List<ChatRoom>
 */
@RequestMapping(path = "/api/public-chats/list/{travelerId}", method = RequestMethod.GET)
public List<ChatRoom> getPublicChatsByTraveler(@PathVariable int travelerId) {
	ArrayList<ChatRoom> rooms = chatRoomRepository.getByTravelerId(travelerId);
	rooms.removeIf(ChatRoom::isPrivate);
	return rooms;
}
 
Example 5
Project: PopulationSimulator   File: CoupleRule.java   Source Code and License Vote up 5 votes
/**
 <hr>
 <h2>Applies this Rule on the Context param</h2>
 <h3>
 — A Person that didn't reach minium age can't get in couple <br>
 — A Person that already is in couple, can't get in couple with someone else <br>
 — 2 People have to <code>match</code> to get in couple <br>
 See {@link CoupleRule#isMatch(Person, Person)}</h3>
 <hr>
 <h3>
 Created : Alexandre Bolot 10/01 <br>
 Modified : Alexandre Bolot 14/01
 </h3>
 <hr>

 @param context Context to apply this rule onto
 */
@Contract ("null -> fail")
public void apply (@NotNull Context context)
{
    //region --> Check params
    if (context == null) throw new IllegalArgumentException("Contect param is null");
    //endregion

    ArrayList<Person> tmpPeople = new ArrayList<>(context.people());
    if (minimumAge != anyAge) tmpPeople.removeIf(person -> person.data().age() < minimumAge);
    tmpPeople.removeIf(person -> context.relations().stream().anyMatch(relation -> relation.involves(person)));

    for (Person person1 : tmpPeople)
    {
        for (Person person2 : tmpPeople)
        {
            if (person2.equals(person1)) continue;
            if (context.relations().contains(relation -> relation.involves(person1))) continue;
            if (context.relations().contains(relation -> relation.involves(person2))) continue;

            if (isMatch(person1, person2))
            {
                context.relations().add(new Relation(person1, person2, Couple, currentTime()));
                break;
            }
        }
    }
}
 
Example 6
Project: Customerly-Android-SDK   File: Customerly.java   Source Code and License Vote up 5 votes
/**
 * Call this method to re-enable an Activity previously disabled with {@link #disableOn(Class)}.
 * @param activityClass The Activity class
 * @see #disableOn(Class)
 */
public void enableOn(Class<? extends Activity> activityClass) {
    ArrayList<Class<? extends Activity>> disabledActivities = this._DisabledActivities;
    if(disabledActivities != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            disabledActivities.removeIf(c -> c == activityClass);
        } else {
            disabledActivities.remove(activityClass);
        }
    }
}