Example usage for com.google.common.collect Multimap equals

List of usage examples for com.google.common.collect Multimap equals

Introduction

In this page you can find the example usage for com.google.common.collect Multimap equals.

Prototype

@Override
boolean equals(@Nullable Object obj);

Source Link

Document

Compares the specified object with this multimap for equality.

Usage

From source file:me.lucko.luckperms.api.context.MutableContextSet.java

@Override
public boolean equals(Object o) {
    if (o == this)
        return true;
    if (!(o instanceof ContextSet))
        return false;
    final ContextSet other = (ContextSet) o;

    final Multimap<String, String> thisContexts = this.toMultimap();
    final Multimap<String, String> otherContexts = other.toMultimap();
    return thisContexts == null ? otherContexts == null : thisContexts.equals(otherContexts);
}

From source file:org.terasology.crafting.ui.UIAvailableInHandRecipesDisplay.java

public void update() {
    // TODO: Naive approach by comparing all the possible recipes to those currently displayed
    Multimap<String, String> recipes = HashMultimap.create();
    for (Map.Entry<String, CraftInHandRecipe> craftInHandRecipe : registry.getRecipes().entrySet()) {
        String recipeId = craftInHandRecipe.getKey();
        List<CraftInHandRecipe.CraftInHandResult> results = craftInHandRecipe.getValue()
                .getMatchingRecipeResults(character);
        if (results != null) {
            for (CraftInHandRecipe.CraftInHandResult result : results) {
                String resultId = result.getResultId();
                recipes.put(recipeId, resultId);
            }//  w w w.j av a 2 s .  c o  m
        }
    }

    if (!recipes.equals(displayedRecipes)) {
        reloadRecipes();
    }

    super.update();
}

From source file:org.terasology.crafting.ui.hand.CraftInHandAvailableRecipesWidget.java

@Override
public void update(float delta) {
    // TODO: Naive approach by comparing all the possible recipes to those currently displayed
    Multimap<String, List<String>> recipes = HashMultimap.create();
    for (Map.Entry<String, CraftInHandRecipe> craftInHandRecipe : registry.getRecipes().entrySet()) {
        String recipeId = craftInHandRecipe.getKey();
        List<CraftInHandRecipe.CraftInHandResult> results = craftInHandRecipe.getValue()
                .getMatchingRecipeResults(character);
        if (results != null) {
            for (CraftInHandRecipe.CraftInHandResult result : results) {
                List<String> parameters = result.getParameters();
                recipes.put(recipeId, parameters);
            }/*from  ww w  .j ava2 s. co m*/
        }
    }

    if (!recipes.equals(displayedRecipes)) {
        reloadRecipes();
    }
}

From source file:org.terasology.workstation.ui.UIAvailableStationRecipesDisplay.java

public void update() {
    // TODO: Naive approach by comparing all the possible recipes to those currently displayed
    Multimap<String, String> recipes = HashMultimap.create();
    for (Map.Entry<String, CraftingStationRecipe> craftInHandRecipe : registry.getCraftingRecipes(stationType)
            .entrySet()) {/*from w  ww. ja  va 2s.  c o m*/
        String recipeId = craftInHandRecipe.getKey();
        CraftingStationRecipe recipe = craftInHandRecipe.getValue();
        List<CraftingStationRecipe.CraftingStationResult> results = recipe.getMatchingRecipeResults(station,
                componentFromSlot, componentSlotCount, toolFromSlot, toolSlotCount);
        if (results != null) {
            for (CraftingStationRecipe.CraftingStationResult result : results) {
                String resultId = result.getResultId();
                recipes.put(recipeId, resultId);
            }
        }
    }

    if (!recipes.equals(displayedRecipes)) {
        reloadRecipes();
    }

    super.update();
}

From source file:com.tinspx.util.collect.CollectUtils.java

public static <K> boolean equalIgnoreOrder(@Nullable Multimap<K, ?> a, @Nullable Multimap<? super K, ?> b) {
    if (a == null || b == null) {
        return a == null && b == null;
    }//w  ww .java2 s  .co  m
    if (a.size() != b.size()) {
        return false;
    }
    if (a.keySet().size() != b.keySet().size()) {
        return false;
    }
    if (a.equals(b)) {
        return true;
    }
    if (a instanceof SetMultimap && b instanceof SetMultimap) {
        return false;
    }
    for (K key : a.keySet()) {
        if (!equalIgnoreOrder(a.get(key), b.get(key))) {
            return false;
        }
    }
    //a and b have the same number distinct keys so don't need to iterate
    //over b keys
    return true;
}

From source file:org.terasology.crafting.ui.workstation.StationAvailableRecipesWidget.java

@Override
public void update(float delta) {
    // TODO: Naive approach by comparing all the possible recipes to those currently displayed
    WorkstationComponent workstation = station.getComponent(WorkstationComponent.class);
    Multimap<String, List<String>> recipes = HashMultimap.create();
    for (WorkstationProcess workstationProcess : registry
            .getWorkstationProcesses(workstation.supportedProcessTypes.keySet())) {
        if (workstationProcess instanceof CraftingWorkstationProcess) {
            CraftingStationRecipe craftingStationRecipe = ((CraftingWorkstationProcess) workstationProcess)
                    .getCraftingWorkstationRecipe();
            String recipeId = workstationProcess.getId();
            List<? extends CraftingStationRecipe.CraftingStationResult> results = craftingStationRecipe
                    .getMatchingRecipeResultsForDisplay(station);
            if (results != null) {
                for (CraftingStationRecipe.CraftingStationResult result : results) {
                    List<String> parameters = result.getResultParameters();
                    recipes.put(recipeId, parameters);
                }// w w  w. jav  a  2 s  .co  m
            }
        }
    }

    if (!openCategories.equals(displayedOpenCategories) || !recipes.equals(availableRecipes)) {
        reloadRecipes();
    }

    layout.update(delta);
}