software.amazon.awssdk.services.costexplorer.model.DateInterval Maven / Gradle / Ivy
/*
* Copyright 2013-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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 software.amazon.awssdk.services.costexplorer.model;
import java.util.Objects;
import java.util.Optional;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.core.protocol.ProtocolMarshaller;
import software.amazon.awssdk.core.protocol.StructuredPojo;
import software.amazon.awssdk.services.costexplorer.transform.DateIntervalMarshaller;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* The time period that you want the usage and costs for.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class DateInterval implements StructuredPojo, ToCopyableBuilder {
private final String start;
private final String end;
private DateInterval(BuilderImpl builder) {
this.start = builder.start;
this.end = builder.end;
}
/**
*
* The beginning of the time period that you want the usage and costs for. The start date is inclusive. For example,
* if start
is 2017-01-01
, then the cost and usage data is retrieved starting at
* 2017-01-01
up to the end date.
*
*
* @return The beginning of the time period that you want the usage and costs for. The start date is inclusive. For
* example, if start
is 2017-01-01
, then the cost and usage data is retrieved
* starting at 2017-01-01
up to the end date.
*/
public String start() {
return start;
}
/**
*
* The end of the time period that you want the usage and costs for. The end date is exclusive. For example, if the
* end
is 2017-05-01
, then the cost and usage data is retrieved from the start date but
* not including 2017-05-01
.
*
*
* @return The end of the time period that you want the usage and costs for. The end date is exclusive. For example,
* if the end
is 2017-05-01
, then the cost and usage data is retrieved from the
* start date but not including 2017-05-01
.
*/
public String end() {
return end;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(start());
hashCode = 31 * hashCode + Objects.hashCode(end());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof DateInterval)) {
return false;
}
DateInterval other = (DateInterval) obj;
return Objects.equals(start(), other.start()) && Objects.equals(end(), other.end());
}
@Override
public String toString() {
return ToString.builder("DateInterval").add("Start", start()).add("End", end()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Start":
return Optional.ofNullable(clazz.cast(start()));
case "End":
return Optional.ofNullable(clazz.cast(end()));
default:
return Optional.empty();
}
}
@SdkInternalApi
@Override
public void marshall(ProtocolMarshaller protocolMarshaller) {
DateIntervalMarshaller.getInstance().marshall(this, protocolMarshaller);
}
public interface Builder extends CopyableBuilder {
/**
*
* The beginning of the time period that you want the usage and costs for. The start date is inclusive. For
* example, if start
is 2017-01-01
, then the cost and usage data is retrieved starting
* at 2017-01-01
up to the end date.
*
*
* @param start
* The beginning of the time period that you want the usage and costs for. The start date is inclusive.
* For example, if start
is 2017-01-01
, then the cost and usage data is
* retrieved starting at 2017-01-01
up to the end date.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder start(String start);
/**
*
* The end of the time period that you want the usage and costs for. The end date is exclusive. For example, if
* the end
is 2017-05-01
, then the cost and usage data is retrieved from the start
* date but not including 2017-05-01
.
*
*
* @param end
* The end of the time period that you want the usage and costs for. The end date is exclusive. For
* example, if the end
is 2017-05-01
, then the cost and usage data is retrieved
* from the start date but not including 2017-05-01
.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder end(String end);
}
static final class BuilderImpl implements Builder {
private String start;
private String end;
private BuilderImpl() {
}
private BuilderImpl(DateInterval model) {
start(model.start);
end(model.end);
}
public final String getStart() {
return start;
}
@Override
public final Builder start(String start) {
this.start = start;
return this;
}
public final void setStart(String start) {
this.start = start;
}
public final String getEnd() {
return end;
}
@Override
public final Builder end(String end) {
this.end = end;
return this;
}
public final void setEnd(String end) {
this.end = end;
}
@Override
public DateInterval build() {
return new DateInterval(this);
}
}
}