Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## lp.struct
Class LpAbstractStructureUnit

    java.lang.Object
      lp.struct.LpAbstractStructureUnit

All Implemented Interfaces:
  LpStructureUnit

Direct Known Subclasses:
  LpAtom, LpCompoundTerm, LpConstant, LpFunction, LpLiteral, LpPredicate, LpRule, LpVariable

    public abstract class LpAbstractStructureUnit

extends Object
implements LpStructureUnit

This abstract class offers a default implementation of the `toString()` method for all classes implementing the `LpStructureUnit` interface.

Version:
  1.0.0
Author:
  Martin Slota
See Also:
  `LpStructureUnit`, `LpConstant`, `LpVariable`, `LpCompoundTerm`, `LpFunction`, `LpPredicate`, `LpAtom`, `LpLiteral`, `LpRule`

Field Summary
`protected static LpBuffer` | `TO_STRING_BUFFER` A single `LpBuffer` instance for the toString() method.

Constructor Summary
`LpAbstractStructureUnit()`

Method Summary
`String` | `toString()`
`protected static
`<T> List<T>`
` | `toUnmodifiableList(List<T> list)` Converts the given list to an unmodifiable list using the `Collections.unmodifiableList(List)` method.
`protected static
`<T> Set<T>`
` | `toUnmodifiableSet(Set<T> set)` Converts the given set to an unmodifiable set using the `Collections.unmodifiableSet(Set)` method.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface lp.struct.LpStructureUnit
`accept`

Field Detail

### TO_STRING_BUFFER

    protected static final LpBuffer TO_STRING_BUFFER

  A single `LpBuffer` instance for the toString() method. All calls to `toString()` are synchronized on it, so it is not a good idea to call `toString()` on `LpStructureUnit`s from many threads...

Constructor Detail

### LpAbstractStructureUnit

    public LpAbstractStructureUnit()

Method Detail

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### toUnmodifiableList

    protected static <T> List<T> toUnmodifiableList(List<T> list)

  Converts the given list to an unmodifiable list using the `Collections.unmodifiableList(List)` method. But there are two differences:
  - on `null` input an empty list is returned (see `Collections.emptyList()`)
  - if the list throws an `UnsupportedOperationException` when we call its `List.addAll(Collection)` method, it is not wrapped in another protecting object. This prevents stacking of `UnmodifiableList` instances.

  Parameters:
    `list` - the list whose read-only view should be returned
  Returns:
    as specified above

### toUnmodifiableSet

    protected static <T> Set<T> toUnmodifiableSet(Set<T> set)

  Converts the given set to an unmodifiable set using the `Collections.unmodifiableSet(Set)` method. But there are two differences:
  - on `null` input an empty set is returned (see `Collections.emptySet()`)
  - if the set throws an `UnsupportedOperationException` when we call its `Set.addAll(Collection)` method, it is not wrapped in another protecting object. This prevents stacking of `UnmodifiableSet` instances.

  Parameters:
    `set` - the set whose read-only view should be returned
  Returns:
    as specified above

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD