gt:             return result.hasAdvancedData() || !advancedData.isEmpty();
context: package com.sk89q.craftbook.mechanics.crafting;
  
  import java.io.IOException;
  import java.util.*;
  
  import com.sk89q.craftbook.bukkit.util.CraftBookBukkitUtil;
  import org.bukkit.inventory.ItemStack;
  
  import com.sk89q.craftbook.bukkit.CraftBookPlugin;
  import com.sk89q.craftbook.util.ItemSyntax;
  import com.sk89q.craftbook.util.ItemUtil;
  import com.sk89q.craftbook.util.RegexUtil;
  import com.sk89q.util.yaml.YAMLProcessor;
  
  public class RecipeManager {
  
      public static RecipeManager INSTANCE;
      private Set<Recipe> recipes;
      protected YAMLProcessor config;
  
      public RecipeManager(YAMLProcessor config) {
          INSTANCE = this;
          this.config = config;
          load();
      }
  
      public void load() {
          recipes = new LinkedHashSet<>();
          if (config == null) {
              CraftBookPlugin.logger().severe("Failure loading recipes! Config is null!");
              return; // If the config is null, it can't continue.
          }
  
          try {
              config.load();
          } catch (IOException e) {
              CraftBookPlugin.logger().severe("Corrupt Custom Crafting crafting-recipes.yml File! Make sure that the correct syntax has been used, and that there are no tabs!");
              e.printStackTrace();
          }
  
          config.setHeader(
                  "# CraftBook Custom Recipes. CraftBook Version: " + CraftBookPlugin.inst().getDescription().getVersion(),
                  "# For more information on setting up custom recipes, see the wiki:",
                  "# " + CraftBookPlugin.getWikiDomain() + "/Custom_crafting",
                  "",
                  "");
  
          List<String> keys = config.getKeys("crafting-recipes");
          if (keys != null) {
              for (String key : keys) {
                  try {
                      recipes.add(new Recipe(key, config));
                  } catch (InvalidCraftingException e) {
                      CraftBookBukkitUtil.printStacktrace(e);
                  }
              }
          }
      }
  
      public void disable() {
          INSTANCE = null;
      }
  
      public void save() {
          if (config == null) {
              CraftBookPlugin.logger().severe("Failure saving recipes! Config is null!");
              return; // If the config is null, it can't continue.
          }
  
          config.clear();
  
          config.setHeader(
                  "# CraftBook Custom Recipes. CraftBook Version: " + CraftBookPlugin.inst().getDescription().getVersion(),
                  "# For more information on setting up custom recipes, see the wiki:",
                  "# " + CraftBookPlugin.getWikiDomain() + "/Custom_crafting",
                  "",
                  "");
  
          config.addNode("crafting-recipes");
          for(Recipe recipe : recipes)
              recipe.save();
  
          config.save();
  
          load();
      }
  
      public Collection<Recipe> getRecipes() {
          return recipes;
      }
  
      public void addRecipe(Recipe rec) {
          recipes.add(rec);
          save();
      }
  
      public boolean removeRecipe(String name) {
          Iterator<Recipe> recs = recipes.iterator();
          while(recs.hasNext()) {
  
              Recipe rec = recs.next();
              if(rec.getId().equalsIgnoreCase(name)) {
                  recs.remove();
                  save();
                  return true;
              }
          }
  
          return false;
      }
  
      public final class Recipe {
          private final String id;
  
          private RecipeType type;
          private List<CraftingItemStack> ingredients;
          private LinkedHashMap<CraftingItemStack, Character> items;
          private CraftingItemStack result;
          private List<String> shape;
  
          private float experience;
          private int cookTime;
  
          @Override
          public boolean equals(Object o) {
              if(o instanceof Recipe) {
                  if(shape != null)
                      if(shape.size() != ((Recipe)o).shape.size())
                          return false;
                  if(ingredients != null) {
                      if(ingredients.size() != ((Recipe)o).ingredients.size())
                          return false;
                      List<CraftingItemStack> stacks = new ArrayList<>(ingredients);
                      for(CraftingItemStack st : ((Recipe)o).ingredients) {
                          if(stacks.size() <= 0)
                              return false;
                          Iterator<CraftingItemStack> it = stacks.iterator();
                          while(it.hasNext()) {
                              CraftingItemStack sta = it.next();
                              if(st.equals(sta)) {
                                  it.remove();
                                  break;
                              }
                          }
                      }
  
                      if(stacks.size() > 0)
                          return false;
                  }
                  if(items != null) {
                      if(items.size() != ((Recipe)o).items.size())
                          return false;
  
                      List<CraftingItemStack> stacks = new ArrayList<>(items.keySet());
                      for(CraftingItemStack st : ((Recipe)o).items.keySet()) {
                          if(stacks.size() <= 0)
                              return false;
                          Iterator<CraftingItemStack> it = stacks.iterator();
                          while(it.hasNext()) {
                              CraftingItemStack sta = it.next();
                              if(st.equals(sta)) {
                                  it.remove();
                                  break;
                              }
                          }
                      }
  
                      if(stacks.size() > 0)
                          return false;
                  }
                  if(advancedData != null)
                      if(advancedData.size() != ((Recipe)o).advancedData.size())
                          return false;
                  return ((Recipe) o).id.equals(id) && type == ((Recipe)o).type && result.equals(((Recipe)o).result);
              }
              else
                  return false;
          }
  
          @Override
          public int hashCode() {
              int ret = id.hashCode();
              if(ingredients != null)
                  ret += ingredients.hashCode();
              else if (items != null)
                  ret += items.hashCode();
              ret += result.hashCode();
              if(shape != null)
                  ret += shape.hashCode();
              return ret + advancedData.hashCode();
          }
  
          public boolean hasAdvancedData() {
              if(ingredients != null) {
                  for(CraftingItemStack stack : ingredients)
                      if(stack.hasAdvancedData())
                          return true;
              }
              if(items != null) {
                  for(CraftingItemStack stack : items.keySet())
                      if(stack.hasAdvancedData())
                          return true;
              }
  