/** * * @param speciesReferences * @param species * @return */ private static boolean contains(ListOf<? extends SimpleSpeciesReference> speciesReferences, Species species) { return speciesReferences.firstHit(new SpeciesReferenceFilter(species)) != null; }
/** * Removes the first element from this list that is accepted by the {@link Filter#accepts(Object)} * method of the given filter. * * @param f a {@link Filter} to apply * @return the removed element or null if no elements satisfied the filter */ public T removeFirst(Filter f) { T t = firstHit(f); if (remove(t)) { return t; } return null; }
/** * Checks whether the given list references the given species. * * @param list * @param s * @return */ private boolean references(ListOf<? extends SimpleSpeciesReference> list, Species s) { if (list != null) { return list.firstHit(new SpeciesReferenceFilter(s)) != null; } return false; }
/** * Gets the {@link Group} that has the given id. * * @param sbmlID * @return the {@link Group} that has the given id or {@code null} if no * {@link Group} is found that matches {@code sbmlID}. */ public SBase getGroup(String sbmlID) { if (isSetListOfGroups()) { return listOfGroups.firstHit(new NameFilter(sbmlID)); } return null; }
/** * Gets the {@link MultiSpeciesType} that has the given id. * * @param id * @return the {@link MultiSpeciesType} that has the given id or null if * no {@link MultiSpeciesType} are found that match {@code id}. */ public MultiSpeciesType getSpeciesType(String id) { if (isSetListOfSpeciesTypes()) { return listOfSpeciesTypes.firstHit(new NameFilter(id)); } return null; }
/** * Gets the {@link QualitativeSpecies} that has the given id. * * @param id * @return the {@link QualitativeSpecies} that has the given id or null if * no {@link QualitativeSpecies} are found that match {@code id}. */ public QualitativeSpecies getQualitativeSpecies(String id) { if (isSetListOfQualitativeSpecies()) { return listOfQualitativeSpecies.firstHit(new NameFilter(id)); } return null; }
/** * Searches the first {@link UnitDefinition} within this {@link Model}'s * {@link #listOfUnitDefinitions} that * is identical to the given {@link UnitDefinition}. If no element can be * found that satisfies the method * {@link UnitDefinition#areIdentical(UnitDefinition, UnitDefinition)}, * {@code null} will be returned. * * @param unitDefinition a {@link UnitDefinition} * @return A {@link UnitDefinition} object that is already part of this * {@link Model}'s {@link #listOfUnitDefinitions} and satisfies the * condition of * {@link UnitDefinition#areIdentical(UnitDefinition, UnitDefinition)} * in comparison to the given {@link UnitDefinition}, or * {@code null} if no such element can be found. */ public UnitDefinition findIdentical(UnitDefinition unitDefinition) { return getListOfUnitDefinitions().firstHit( new IdenticalUnitDefinitionFilter(unitDefinition)); }
/** * Searches the first {@link SpeciesReference} in the listOfReactants of * this {@link Reaction} with the given identifier. * * @param id * identifier of the desired {@link SpeciesReference}. Note that * this is not the identifier of the {@link Species}. * @return the {@link SpeciesReference} of the listOfReactants which has * 'id' as id (or name depending on the level and version). Can be * null if it doesn't exist. */ public SpeciesReference getReactant(String id) { if (isSetListOfReactants()) { return getListOfReactants().firstHit(new NameFilter(id)); } return null; }
/** * Searches for the first instance of {@link ExplicitRule} within this * {@link Model}'s {@link #listOfRules}, whose variable attribute is set to * the value passed to this method. * * @param variable the variable to search for. * @return {@code null} if no element with the required property exists. */ public ExplicitRule getRuleByVariable(String variable) { if (isSetListOfRules()) { Rule rule = getListOfRules().firstHit(new AssignmentVariableFilter(variable)); return (rule != null) && (rule instanceof ExplicitRule) ? (ExplicitRule) rule : null; } return null; }
/** * Searches the first {@link SpeciesReference} in the listOfProducts of this * {@link Reaction} with the given identifier. * * @param id * identifier of the desired {@link SpeciesReference}. Note that * this is not the identifier of the {@link Species}. * @return the {@link SpeciesReference} of the {@link #listOfProducts} which has 'id' as id * (or name depending on the level and version). Can be null if it * doesn't exist. */ public SpeciesReference getProduct(String id) { if (isSetListOfProducts()) { return getListOfProducts().firstHit(new NameFilter(id)); } return null; }
/** * Searches the first {@link ModifierSpeciesReference} in the * {@link #listOfModifiers} of this {@link Reaction} with the given * identifier. * * @param id * identifier of the desired {@link ModifierSpeciesReference}. * Note that this is not the identifier of the {@link Species}. * @return the {@link ModifierSpeciesReference} of the * {@link #listOfModifiers} which has 'id' as id (or name depending * on the level and version). Can be null if it doesn't exist. */ public ModifierSpeciesReference getModifier(String id) { if (isSetListOfModifiers()) { return getListOfModifiers().firstHit(new NameFilter(id)); } return null; }
/** * Returns the {@link InitialAssignment} of the * {@link #listOfInitialAssignments} whose {@code symbol} attribute, * i.e., whose {@link Variable} has the given {@code variable} as * identifier. * * @param variable * The identifier of a variable, for which a corresponding * {@link InitialAssignment} is requested. * @return the first {@link InitialAssignment} of the * {@link #listOfInitialAssignments}, whose {@link Variable} has the * {@code variable} as identifier (or name depending on the level * and version). {@code null} if it doesn't exist. * */ public InitialAssignment getInitialAssignmentBySymbol(String variable) { if (isSetListOfInitialAssignments()) { return getListOfInitialAssignments().firstHit( new AssignmentVariableFilter(variable)); } return null; }
/** * Gets the {@link Transition} that has the given id. * * @param id * @return the {@link Transition} that has the given id or null if * no {@link Transition} are found that match {@code id}. */ public Transition getTransition(String id) { if (isSetListOfTransitions()) { Model m = getModel(); if (m != null) { return (Transition) m.findNamedSBase(id); } return listOfTransitions.firstHit(new NameFilter(id)); } return null; }
/** * Returns the first {@link SpeciesReference} in the * {@link #listOfReactants} of this {@link Reaction} whose 'species' * attribute points to a {@link Species} with the given identifier. * * @param id * The identifier of a referenced {@link Species} * @return the {@link SpeciesReference} of the {@link #listOfReactants} * which has 'id' as species attribute (or name depending on the * level and version). Can be null if it doesn't exist. */ public SpeciesReference getReactantForSpecies(String id) { if (isSetListOfReactants()) { SpeciesReferenceFilter srf = new SpeciesReferenceFilter(id); srf.setFilterForSpecies(true); return getListOfReactants().firstHit(srf); } return null; }
/** * Returns the first {@link SpeciesReference} in the {@link #listOfProducts} * of this {@link Reaction} whose 'species' attribute points to a * {@link Species} with the given identifier. * * @param id * The identifier of a referenced {@link Species} * @return the {@link SpeciesReference} of the {@link #listOfProducts} which * has 'id' as species attribute (or name depending on the level and * version). Can be null if it doesn't exist. */ public SpeciesReference getProductForSpecies(String id) { if (isSetListOfProducts()) { SpeciesReferenceFilter srf = new SpeciesReferenceFilter(id); srf.setFilterForSpecies(true); return getListOfProducts().firstHit(srf); } return null; }
/** * Returns the first {@link ModifierSpeciesReference} in the * {@link #listOfModifiers} of this {@link Reaction} whose 'species' * attribute points to a {@link Species} with the given identifier. * * @param id * The identifier of a referenced {@link Species} * @return the {@link ModifierSpeciesReference} of the * {@link #listOfModifiers} which has 'id' as species attribute (or * name depending on the level and version). Can be null if it * doesn't exist. */ public ModifierSpeciesReference getModifierForSpecies(String id) { if (isSetListOfModifiers()) { SpeciesReferenceFilter srf = new SpeciesReferenceFilter(id); srf.setFilterForSpecies(true); return getListOfModifiers().firstHit(srf); } return null; }