@Override public final int hashCode() { int hashCode = 0; for (Binding binding : this) { hashCode ^= binding.getName().hashCode() ^ binding.getValue().hashCode(); } return hashCode; }
@Override public boolean equals(Object o) { if (o instanceof Binding) { Binding other = (Binding)o; return name.equals(other.getName()) && value.equals(other.getValue()); } return false; }
@Override public final int hashCode() { int hashCode = 0; for (Binding binding : this) { hashCode ^= binding.getName().hashCode() ^ binding.getValue().hashCode(); } return hashCode; }
public Value getValue(String bindingName) { Binding binding = getBinding(bindingName); if (binding != null) { return binding.getValue(); } return null; }
/******************************************************************************************************************* * ******************************************************************************************************************/ @Nonnull protected static Optional<Long> toLong (final @Nullable Binding binding) { return Optional.ofNullable(binding).map(b -> b.getValue()).map(v -> Long.parseLong(v.stringValue())); }
@Override public final int hashCode() { int hashCode = 0; for (Binding binding : this) { hashCode ^= binding.getName().hashCode() ^ binding.getValue().hashCode(); } return hashCode; }
@Override public boolean equals(Object o) { if (o instanceof Binding) { Binding other = (Binding)o; return name.equals(other.getName()) && value.equals(other.getValue()); } return false; }
public Value getValue(String bindingName) { Binding binding = getBinding(bindingName); if (binding != null) { return binding.getValue(); } return null; }
/******************************************************************************************************************* * ******************************************************************************************************************/ @Nonnull protected static Optional<String> toString (final @Nullable Binding binding) { return Optional.ofNullable(binding).map(b -> b.getValue()).map(v -> v.stringValue()); }
/******************************************************************************************************************* * ******************************************************************************************************************/ @Nonnull protected static Optional<Integer> toInteger (final @Nullable Binding binding) { return Optional.ofNullable(binding).map(b -> b.getValue()).map(v -> Integer.parseInt(v.stringValue())); }
/******************************************************************************************************************* * ******************************************************************************************************************/ @Nonnull protected static Optional<Id> toId (final @Nullable Binding binding) { return Optional.ofNullable(binding).map(b -> b.getValue()).map(v -> v.stringValue()).map(s -> new Id(s)); }
@Override public String toString() { final StringBuilder sb = new StringBuilder(); sb.append(" names: "); for (final String name : getBindingNames()) { sb.append("\n [name]: " + name + " --- [value]: " + getBinding(name).getValue().toString()); } return sb.toString(); } }
@Override @Nonnull public String apply (final @Nonnull Repository repository, final @Nonnull BindingSet bindingSet) { return bindingSet.iterator().next().getValue().stringValue(); } }
public RepositoryMusicPerformer (final @Nonnull Repository repository, final @Nonnull BindingSet bindingSet) { this.musicArtist = new RepositoryMusicArtist(repository, bindingSet); final Optional<String> r = Optional.of(bindingSet.getBinding("role").getValue().stringValue() .replaceAll(BMMO.NS + "performer_", "")); this.role = r.map(RepositoryMusicPerformerRole::new); }
/** * Adds a new binding to the binding set. The binding's name must not already be part of this binding set. * * @param binding * The binding to add this this BindingSet. */ public void addBinding(Binding binding) { addBinding(binding.getName(), binding.getValue()); }
/** * Adds a new binding to the binding set. The binding's name must not already be part of this binding set. * * @param binding * The binding to add this this BindingSet. */ public void addBinding(Binding binding) { addBinding(binding.getName(), binding.getValue()); }
/** * Adds a new binding to the binding set. The binding's name must not already be part of this binding set. * * @param binding * The binding to add this this BindingSet. */ public void addBinding(Binding binding) { addBinding(binding.getName(), binding.getValue()); }
/** * Adds a new binding to the binding set. The binding's name must not already be part of this binding set. * * @param binding * The binding to add this this BindingSet. */ public void addBinding(Binding binding) { addBinding(binding.getName(), binding.getValue()); }
/** * Adds a new binding to the binding set. The binding's name must not already be part of this binding set. * * @param binding * The binding to add this this BindingSet. */ public void addBinding(Binding binding) { addBinding(binding.getName(), binding.getValue()); }
public RepositoryAudioFile (final @Nonnull Repository repository, final @Nonnull BindingSet bindingSet) { super(repository, bindingSet, "audioFile", rdfsLabelOf(bindingSet.getBinding("path").getValue().stringValue())); this.path = toPath(bindingSet.getBinding("path")); this.duration = toDuration(bindingSet.getBinding("duration")); this.fileSize = toLong(bindingSet.getBinding("fileSize")); this.trackId = toId(bindingSet.getBinding("track")); this.metadata = new MetadataSupport(path).with(TITLE, rdfsLabel) .with(DURATION, duration) .with(FILE_SIZE, fileSize) .withFallback(key -> fallbackMetadata.get(this::loadFallbackMetadata)); }