![JAR search and dependency download from the Maven repository](/logo.png)
org.n52.shetland.ogc.om.values.TLVTValue Maven / Gradle / Ivy
/*
* Copyright (C) 2015-2022 52°North Spatial Information Research GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.n52.shetland.ogc.om.values;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.n52.shetland.ogc.UoM;
import org.n52.shetland.ogc.gml.time.Time;
import org.n52.shetland.ogc.gml.time.TimePeriod;
import org.n52.shetland.ogc.om.TimeLocationValueTriple;
import org.n52.shetland.ogc.om.values.visitor.ValueVisitor;
import org.n52.shetland.util.CollectionHelper;
/**
* {@link MultiValue} representing a time location value triple for observations
*
* @since 1.0.0
*
*/
public class TLVTValue implements MultiValue> {
/**
* Mesurement values
*/
private List value = new ArrayList(0);
/**
* Unit of measure
*/
private UoM unit;
@Override
public TLVTValue setValue(List value) {
this.value.clear();
if (value != null) {
this.value.addAll(value);
}
return this;
}
@Override
public List getValue() {
Collections.sort(value);
return Collections.unmodifiableList(value);
}
/**
* Add time value pair value
*
* @param value
* Time value pair value to add
* @return this
*/
public TLVTValue addValue(TimeLocationValueTriple value) {
if (value != null) {
this.value.add(value);
}
return this;
}
/**
* Add time value pair values
*
* @param values
* Time value pair values to add
* @return this
*/
public TLVTValue addValues(List values) {
if (values != null) {
this.value.addAll(values);
}
return this;
}
@Override
public void setUnit(String unit) {
this.unit = new UoM(unit);
}
@Override
public TLVTValue setUnit(UoM unit) {
this.unit = unit;
return this;
}
@Override
public String getUnit() {
if (isSetUnit()) {
return unit.getUom();
}
return null;
}
@Override
public UoM getUnitObject() {
return this.unit;
}
@Override
public Time getPhenomenonTime() {
TimePeriod timePeriod = new TimePeriod();
if (isSetValue()) {
for (TimeLocationValueTriple timeValuePair : getValue()) {
timePeriod.extendToContain(timeValuePair.getTime());
}
}
return timePeriod;
}
@Override
public boolean isSetValue() {
return CollectionHelper.isNotEmpty(getValue());
}
@Override
public <
X,
E extends Exception> X accept(ValueVisitor visitor) throws E {
return visitor.visit(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy