@Override public String getDisplayName() { return AbstractFileCollection.this.getDisplayName(); } };
@Override public String toString() { return getDisplayName(); }
@Override public String getDisplayName() { return AbstractFileCollection.this.getDisplayName(); }
@Override public String getDisplayName() { return AbstractFileCollection.this.getDisplayName(); }
protected String getCapDisplayName() { return StringUtils.capitalize(getDisplayName()); }
public File getSingleFile() throws IllegalStateException { Collection<File> files = getFiles(); if (files.isEmpty()) { throw new IllegalStateException(String.format("Expected %s to contain exactly one file, however, it contains no files.", getDisplayName())); } if (files.size() != 1) { throw new IllegalStateException(String.format("Expected %s to contain exactly one file, however, it contains %d files.", getDisplayName(), files.size())); } return files.iterator().next(); }
public Object asType(Class<?> type) throws UnsupportedOperationException { if (type.isAssignableFrom(Set.class)) { return getFiles(); } if (type.isAssignableFrom(List.class)) { return new ArrayList<File>(getFiles()); } if (type.isAssignableFrom(File[].class)) { Set<File> files = getFiles(); return files.toArray(new File[0]); } if (type.isAssignableFrom(File.class)) { return getSingleFile(); } if (type.isAssignableFrom(FileCollection.class)) { return this; } if (type.isAssignableFrom(FileTree.class)) { return getAsFileTree(); } throw new UnsupportedOperationException(String.format("Cannot convert %s to type %s, as this type is not supported.", getDisplayName(), type.getSimpleName())); }