public code v1

This commit is contained in:
Francisco Jesús Martínez Mimbrera
2026-05-23 00:32:57 +02:00
commit 759a8968a2
4357 changed files with 163763 additions and 0 deletions
@@ -0,0 +1,218 @@
package flintstones.valuation.numeric.integer;
import javax.inject.Inject;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.eclipse.e4.core.services.nls.Translation;
import flintstones.domain.numeric.NumericDomain;
import flintstones.domain.numeric.integer.NumericIntegerDomain;
import flintstones.domain.numeric.real.NumericRealDomain;
import flintstones.entity.extensionenum.ExtensionEnum;
import flintstones.entity.valuation.Valuation;
import flintstones.entity.valuation.exception.InvalidValueException;
import flintstones.helper.data.wxml.WNode;
import flintstones.helper.validator.Validator;
import flintstones.model.domain.service.IDomainService;
import flintstones.model.valuation.service.IValuationService;
import flintstones.valuation.numeric.NumericValuation;
import flintstones.valuation.numeric.integer.messages.Messages;
/**
* The Class IntegerValuation.
*/
public class IntegerValuation extends NumericValuation {
@Inject
IDomainService domainService;
@Inject
IValuationService valuationService;
@Inject
@Translation
private Messages messages;
/** The Constant ID. */
public static final String ID = "flintstones.valuation.integer"; //$NON-NLS-1$
/**
* The Enum Fields.
*/
public enum Fields implements ExtensionEnum {
/** The value. */
value
}
/**
* Instantiates a new integer valuation.
*/
public IntegerValuation() {
super();
this.value = 0;
setId(ID);
}
@Override
public void initFromString(String value) throws InvalidValueException {
int iValue;
try{
iValue = Integer.parseInt(value);
} catch(NumberFormatException e) {
throw new InvalidValueException("Value is not integer " + value );
}
setValue(iValue);
}
@Override
public double getValue() {
return this.value;
}
/**
* Sets the value.
*
* @param value the new value
*/
@Override
public void setValue(double value) throws InvalidValueException {
if ((value != Math.floor(value)))
throw new InvalidValueException("Value is not integer " + value);
super.setValue(value);
}
/* (non-Javadoc)
*
* @see flintstones.valuation.Valuation#negateValuation() */
@Override
public Valuation negateValuation() {
IntegerValuation result = (IntegerValuation) this.clone();
long aux = Math.round(((NumericIntegerDomain) (NumericDomain) this.domain).getMin()) + Math.round(((NumericIntegerDomain) this.domain).getMax());
result.setValue(aux - this.value);
return result;
}
/* (non-Javadoc)
*
* @see java.lang.Object#toString() */
@Override
public String toString() {
return ("Integer(" + this.value + ") in" + this.domain.toString()); //$NON-NLS-1$ //$NON-NLS-2$
}
/* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object) */
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj.getClass() != this.getClass())
return false;
final IntegerValuation other = (IntegerValuation) obj;
EqualsBuilder eb = new EqualsBuilder();
eb.append(this.value, other.value);
eb.append(this.domain, other.domain);
return eb.isEquals();
}
/* (non-Javadoc)
*
* @see java.lang.Object#hashCode() */
@Override
public int hashCode() {
HashCodeBuilder hcb = new HashCodeBuilder(17, 31);
hcb.append(this.value);
hcb.append(this.domain);
return hcb.toHashCode();
}
/* (non-Javadoc)
*
* @see java.lang.Comparable#compareTo(java.lang.Object) */
@Override
public int compareTo(Valuation other) {
Validator.notNull(other);
if (this.domain.equals(other.getDomain()))
return Double.valueOf(this.value)
.compareTo(Double.valueOf(((IntegerValuation) other).value));
return 0;
}
/* (non-Javadoc)
*
* @see flintstones.valuation.Valuation#clone() */
@Override
public Object clone() {
IntegerValuation result = null;
result = (IntegerValuation) super.clone();
result.value = Double.valueOf(this.value);
return result;
}
/* (non-Javadoc)
*
* @see flintstones.valuation.Valuation#changeFormatValuationToString() */
@Override
public String changeFormatValuationToString() {
return Double.toString(this.value);
}
/* (non-Javadoc)
*
* @see
* flintstones.valuation.Valuation#write(javax.xml.stream.XMLStreamWriter) */
@Override
public void write(XMLStreamWriter writer) throws XMLStreamException {
writer.writeAttribute(Fields.value.toString(), Double.toString(this.value));
}
/* (non-Javadoc)
*
* @see flintstones.valuation.Valuation#read(flintstones.helper.wxml.WNode) */
@Override
public void read(WNode node) {
this.value = Double.parseDouble(node.getAttribute(Fields.value));
}
@Override
public NumericValuation cloneToNormalize() {
NumericValuation anyValuation = this;
NumericDomain anyDomain = (NumericDomain) anyValuation.getDomain();
NumericRealDomain newDomain = (NumericRealDomain) domainService.create(NumericRealDomain.ID);
newDomain.setInRange( anyDomain.isInRange() );
newDomain.setMax( anyDomain.getMax() );
newDomain.setMin( anyDomain.getMin() );
NumericValuation newValuation = (NumericValuation) valuationService.create(newDomain);
newValuation.setEvaluated( this.isEvaluated() );
return newValuation;
}
}
@@ -0,0 +1,12 @@
// This file has been auto-generated
package flintstones.valuation.numeric.integer.messages;
import org.eclipse.e4.core.services.nls.Message;
@Message
@SuppressWarnings("javadoc")
public class Messages {
public String Not_BLTS_fuzzy_set;
}
@@ -0,0 +1 @@
Not_BLTS_fuzzy_set=Not BLTS fuzzy set
@@ -0,0 +1 @@
Not_BLTS_fuzzy_set=No BLTS fuzzy establecido