Package net.minecraftforge.fml
Class OptionalMod<T>
java.lang.Object
net.minecraftforge.fml.OptionalMod<T>
- 
Field SummaryFields
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprivateOptionalMod(boolean searched) privateOptionalMod(String modId) 
- 
Method SummaryModifier and TypeMethodDescriptionprivate static <T> OptionalMod<T> empty()booleanIf a mod object is present, and the mod object matches the given predicate, return anOptionalModdescribing the value, otherwise return an emptyOptionalMod.<U> Optional<U> If a value is present, apply the providedOptional-bearing mapping function to it, return that result, otherwise return an emptyOptional.get()If a mod is present in thisOptionalMod, returns the value, otherwise throwsNoSuchElementException.getModId()private TgetValue()inthashCode()voidIf a mod object is present, invoke the specified consumer with the object, otherwise do nothing.booleanReturntrueif there is a mod object present, otherwisefalse.<U> Optional<U> If a mod object is present, apply the provided mapping function to it, and if the result is non-null, return anOptionaldescribing the result.static <M> OptionalMod<M> Return the mod object if present, otherwise returnother.Return the mod object if present, otherwise invokeotherand return the result of that invocation.orElseThrow(Supplier<? extends X> exceptionSupplier) Return the contained mod object, if present, otherwise throw an exception to be created by the provided supplier.
- 
Field Details- 
modId
- 
value
- 
searchedprivate boolean searched
- 
EMPTY
 
- 
- 
Constructor Details- 
OptionalModprivate OptionalMod(boolean searched) 
- 
OptionalMod
 
- 
- 
Method Details- 
of
- 
empty
- 
getValue
- 
getIf a mod is present in thisOptionalMod, returns the value, otherwise throwsNoSuchElementException.- Returns:
- the modobject held by this OptionalMod
- Throws:
- NoSuchElementException- if there is no modobject present
- See Also:
 
- 
getModId
- 
isPresentpublic boolean isPresent()Returntrueif there is a mod object present, otherwisefalse.- Returns:
- trueif there is a mod object present, otherwise- false
 
- 
ifPresentIf a mod object is present, invoke the specified consumer with the object, otherwise do nothing.- Parameters:
- consumer- block to be executed if a mod object is present
- Throws:
- NullPointerException- if mod object is present and- consumeris null
 
- 
filterIf a mod object is present, and the mod object matches the given predicate, return anOptionalModdescribing the value, otherwise return an emptyOptionalMod.- Parameters:
- predicate- a predicate to apply to the mod object, if present
- Returns:
- an OptionalModdescribing the value of thisOptionalModif a mod object is present and the mod object matches the given predicate, otherwise an emptyOptionalMod
- Throws:
- NullPointerException- if the predicate is null
 
- 
mapIf a mod object is present, apply the provided mapping function to it, and if the result is non-null, return anOptionaldescribing the result. Otherwise return an emptyOptional.- Type Parameters:
- U- The type of the result of the mapping function
- Parameters:
- mapper- a mapping function to apply to the mod object, if present
- Returns:
- an Optionaldescribing the result of applying a mapping function to the mod object of thisOptionalMod, if a mod object is present, otherwise an emptyOptional
- Throws:
- NullPointerException- if the mapping function is null
- API Note:
- This method supports post-processing on optional values, without the need to explicitly check for a return status.
 
- 
flatMapIf a value is present, apply the providedOptional-bearing mapping function to it, return that result, otherwise return an emptyOptional. This method is similar tomap(Function), but the provided mapper is one whose result is already anOptional, and if invoked,flatMapdoes not wrap it with an additionalOptional.- Type Parameters:
- U- The type parameter to the- Optionalreturned by
- Parameters:
- mapper- a mapping function to apply to the mod object, if present the mapping function
- Returns:
- the result of applying an Optional-bearing mapping function to the value of thisOptional, if a value is present, otherwise an emptyOptional
- Throws:
- NullPointerException- if the mapping function is null or returns a null result
 
- 
orElseReturn the mod object if present, otherwise returnother.- Parameters:
- other- the mod object to be returned if there is no mod object present, may be null
- Returns:
- the mod object, if present, otherwise other
 
- 
orElseGetReturn the mod object if present, otherwise invokeotherand return the result of that invocation.- Parameters:
- other- a- Supplierwhose result is returned if no mod object is present
- Returns:
- the mod object if present otherwise the result of other.get()
- Throws:
- NullPointerException- if mod object is not present and- otheris null
 
- 
orElseThrowReturn the contained mod object, if present, otherwise throw an exception to be created by the provided supplier.- Type Parameters:
- X- Type of the exception to be thrown
- Parameters:
- exceptionSupplier- The supplier which will return the exception to be thrown
- Returns:
- the present mod object
- Throws:
- X- if there is no mod object present
- NullPointerException- if no mod object is present and- exceptionSupplieris null
- API Note:
- A method reference to the exception constructor with an empty
 argument list can be used as the supplier. For example,
 IllegalStateException::new
 
- 
equals
- 
hashCodepublic int hashCode()
 
-