本文整理汇总了Java中de.pfabulist.kleinod.collection.Ref类的典型用法代码示例。如果您正苦于以下问题:Java Ref类的具体用法?Java Ref怎么用?Java Ref使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Ref类属于de.pfabulist.kleinod.collection包,在下文中一共展示了Ref类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findFile
import de.pfabulist.kleinod.collection.Ref; //导入依赖的package包/类
public Optional<Path> findFile( Path base ) {
final Ref<Optional<Path>> ret = Ref.valueOf( Optional.empty() );
try {
Files.walkFileTree(base, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile( Path file,
BasicFileAttributes attrs) throws IOException {
if ( !attrs.isDirectory() ) {
ret.set( Optional.of( file ));
return FileVisitResult.TERMINATE;
}
return FileVisitResult.CONTINUE;
}
});
} catch (IOException e) {
throw u( e );
}
return ret.get();
}
示例2: testWatchServiceTakeBlocks
import de.pfabulist.kleinod.collection.Ref; //导入依赖的package包/类
@Test
@Category( { SlowTest.class, Watchable.class, Writable.class } )
@SuppressWarnings( "PMD.EmptyCatchBlock" )
public void testWatchServiceTakeBlocks() throws Exception {
Path dir = dirTA();
final WatchService watcher = dir.getFileSystem().newWatchService();
dir.register( watcher, ENTRY_CREATE );
final Ref<Boolean> interrupted = Ref.valueOf( false );
new Thread( () -> {
try {
watcher.take();
} catch( InterruptedException | ClosedWatchServiceException e ) {
// nothing to do
} finally {
interrupted.set( true );
}
} ).start();
Thread.sleep( 1000 );
assertThat( interrupted.get() ).isFalse();
}
示例3: testOnClose
import de.pfabulist.kleinod.collection.Ref; //导入依赖的package包/类
@Test
public void testOnClose() throws IOException {
Ref<String> external = Ref.valueOf( "open" );
Path hostcl3 = Pathss.getTmpDir( "cl3test" );
Files.createDirectories( hostcl3 );
FileSystem fscl = CloseableProvider.getUrim().getOrCreateFS(
hostcl3,
Collections.singletonMap( "external", external ) );
fscl.close();
assertThat( external.get()).isEqualTo( "closed" );
}
示例4: CloseableFS
import de.pfabulist.kleinod.collection.Ref; //导入依赖的package包/类
public CloseableFS( Path hostRoot, Ref<String> external ) {
super( hostRoot );
this.external = external;
}
示例5: create
import de.pfabulist.kleinod.collection.Ref; //导入依赖的package包/类
public static EightyFS create( Object hostRoot, RWAttributesBuilder ab, Map<String, Object> env ) {
ab.addPosix().addOwner();
return new CloseableFS( (Path) hostRoot, (Ref<String>) env.get("external") );
}