com.farao_community.farao.data.crac_impl.OnInstantImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of farao-crac-impl Show documentation
Show all versions of farao-crac-impl Show documentation
Object model for CRAC implementation
/*
* Copyright (c) 2020, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.farao_community.farao.data.crac_impl;
import com.farao_community.farao.data.crac_api.Instant;
import com.farao_community.farao.data.crac_api.State;
import com.farao_community.farao.data.crac_api.usage_rule.OnInstant;
import com.farao_community.farao.data.crac_api.usage_rule.UsageMethod;
/**
* The UsageMethod of the OnInstantImpl UsageRule is effective in all the States which
* are at a given Instant.
*
* @author Viktor Terrier {@literal }
* @author Baptiste Seguinot {@literal }
*/
public final class OnInstantImpl extends AbstractUsageRule implements OnInstant {
private Instant instant;
OnInstantImpl(UsageMethod usageMethod, Instant instant) {
super(usageMethod);
this.instant = instant;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
OnInstantImpl rule = (OnInstantImpl) o;
return super.equals(o) && rule.getInstant().equals(instant);
}
@Override
public int hashCode() {
return usageMethod.hashCode() * 19 + instant.hashCode() * 47;
}
@Override
public UsageMethod getUsageMethod(State state) {
return state.getInstant().equals(instant) ? usageMethod : UsageMethod.UNDEFINED;
}
@Override
public Instant getInstant() {
return instant;
}
}