de.mklinger.qetcher.client.model.v1.impl.AvailableConversionImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of qetcher-client-bundle Show documentation
Show all versions of qetcher-client-bundle Show documentation
Qetcher Java client, OSGi bundle, minimal dependencies
package de.mklinger.qetcher.client.model.v1.impl;
import java.util.List;
import java.util.Objects;
import de.mklinger.micro.lists.Lists;
import de.mklinger.qetcher.client.model.v1.Availability;
import de.mklinger.qetcher.client.model.v1.AvailableConversion;
import de.mklinger.qetcher.client.model.v1.Conversion;
import de.mklinger.qetcher.client.model.v1.ModelValidationException;
import de.mklinger.qetcher.client.model.v1.builder.AvailableConversionBuilder;
/**
* @author Marc Klinger - mklinger[at]mklinger[dot]de
*/
public class AvailableConversionImpl implements AvailableConversion {
private final List availabilities;
private final Conversion conversion;
public AvailableConversionImpl(final AvailableConversionBuilder builder) {
this.availabilities = Lists.newImmutableList(builder.getAvailabilities());
this.conversion = builder.getConversion();
try {
validate();
} catch (final Exception e) {
throw new ModelValidationException(AvailableConversion.class, e);
}
}
private void validate() {
Objects.requireNonNull(availabilities);
if (availabilities.isEmpty()) {
throw new IllegalArgumentException("Availabilities must not be empty");
}
Objects.requireNonNull(conversion);
}
@Override
public List getAvailabilities() {
return availabilities;
}
@Override
public Conversion getConversion() {
return conversion;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy