All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jdplus.toolkit.desktop.plugin.workspace.WorkspaceItemRepositoryLoader Maven / Gradle / Ivy

package jdplus.toolkit.desktop.plugin.workspace;

import java.lang.Iterable;
import java.util.Optional;
import java.util.ServiceLoader;
import java.util.stream.StreamSupport;

/**
 * Custom service loader for {@link jdplus.toolkit.desktop.plugin.workspace.WorkspaceItemRepository}.
 * 
This class is thread-safe. *

Properties: *

    *
  • Quantifier: OPTIONAL
  • *
  • Fallback: null
  • *
  • Preprocessing: null
  • *
  • Mutability: NONE
  • *
  • Singleton: false
  • *
  • Name: null
  • *
  • Backend: null
  • *
  • Cleaner: null
  • *
  • Batch: false
  • *
  • Batch name: null
  • *
*/ public final class WorkspaceItemRepositoryLoader { private final Iterable source = ServiceLoader.load(WorkspaceItemRepository.class); private final Optional resource = doLoad(); private Optional doLoad() { return StreamSupport.stream(source.spliterator(), false) .findFirst(); } /** * Gets an optional {@link jdplus.toolkit.desktop.plugin.workspace.WorkspaceItemRepository} instance. *
This method is thread-safe. * @return the current non-null value */ public Optional get() { return resource; } /** * Gets an optional {@link jdplus.toolkit.desktop.plugin.workspace.WorkspaceItemRepository} instance. *
This is equivalent to the following code: new WorkspaceItemRepositoryLoader().get() *
Therefore, the returned value might be different at each call. *
This method is thread-safe. * @return a non-null value */ public static Optional load() { return new WorkspaceItemRepositoryLoader().get(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy