/** * Return the binary filename. * * @return */ default String getFileName() { return property(BINARY_FILENAME_PROPERTY_KEY); }
/** * Clear the metadata properties. */ default void clearMetadata() { setLocationAltitude(null); setLocationLongitude(null); setLocationLatitude(null); // Remove all other metadata properties getPropertyKeys().stream() .filter(e -> e.startsWith(META_DATA_PROPERTY_PREFIX)) .forEach(e -> { setMetadata(e.substring(META_DATA_PROPERTY_PREFIX.length()), null); }); }
/** * Remove the field and use a dummy bulk action context. * * @param container */ default void removeField(GraphFieldContainer container) { removeField(new DummyBulkActionContext(), container); }
@Override public boolean exists(BinaryGraphField field) { String uuid = field.getBinary().getUuid(); return new File(getFilePath(uuid)).exists(); }
/** * Increment any found postfix number in the filename. * * e.g: * <ul> * <li>test.txt -> test_1.txt</li> * <li>test -> test_1</li> * <li>test.blub.txt -> test.blub_1.txt</li> * <ul> * */ default void postfixFileName() { String oldName = getFileName(); if (oldName != null && !oldName.isEmpty()) { setFileName(UniquenessUtil.suggestNewName(oldName)); } }
/** * Set the location information. * * @param loc */ default void setLocation(Location loc) { Objects.requireNonNull(loc, "A valid location object needs to be supplied. Got null."); setLocationLatitude(loc.getLat()); setLocationLongitude(loc.getLon()); Integer alt = loc.getAlt(); if (alt != null) { setLocationAltitude(alt); } }
/** * Compare both fields by using the equals implementation and return a field container change list that contains the detected changes. * * @param field * @return List of detected changes or empty list if no change has been detected */ default List<FieldContainerChange> compareTo(Object field) { if (!equals(field)) { return Arrays.asList(new FieldContainerChange(getFieldKey(), FieldChangeTypes.UPDATED)); } return Collections.emptyList(); } }
/** * Set the location latitude. * * @param lat */ default void setLocationLatitude(Double lat) { property(BINARY_LAT_KEY, lat); }
/** * Set the location longitude. * * @param lon */ default void setLocationLongitude(Double lon) { property(BINARY_LON_KEY, lon); }
/** * Return the binary mime type of the node. * * @return */ default String getMimeType() { return property(BINARY_CONTENT_TYPE_PROPERTY_KEY); }
/** * Set the binary mime type of the node. * * @param mimeType * @return Fluent API */ default BinaryGraphField setMimeType(String mimeType) { property(BINARY_CONTENT_TYPE_PROPERTY_KEY, mimeType); return this; }
/** * Return the location latitude. * * @return */ default Double getLocationLatitude() { return property(BINARY_LAT_KEY); }
/** * Return the location longitude. * * @return */ default Double getLocationLongitude() { return property(BINARY_LON_KEY); }
/** * Set the binary filename. * * @param fileName * @return Fluent API */ default BinaryGraphField setFileName(String fileName) { property(BINARY_FILENAME_PROPERTY_KEY, fileName); return this; }
/** * Set the binary image dominant color. * * @param dominantColor * @return Fluent API */ default BinaryGraphField setImageDominantColor(String dominantColor) { property(BINARY_IMAGE_DOMINANT_COLOR_PROPERTY_KEY, dominantColor); return this; }
/** * Return the binary image dominant color. * * @return */ default String getImageDominantColor() { return property(BINARY_IMAGE_DOMINANT_COLOR_PROPERTY_KEY); }
/** * Return the location altitude. * * @return */ default Integer getLocationAltitude() { return property(BINARY_ALT_KEY); }
/** * Set the location altitude. * * @param alt */ default void setLocationAltitude(Integer alt) { property(BINARY_ALT_KEY, alt); }
/** * Return the stored focal point of the image. * * @return Focal point or null if no focal point has been set */ default FocalPoint getImageFocalPoint() { Float x = property(BINARY_IMAGE_FOCAL_POINT_X); Float y = property(BINARY_IMAGE_FOCAL_POINT_Y); if (x == null || y == null) { return null; } return new FocalPoint(x, y); }