Package fr.univ_eiffel.legotools.model
Record Class FactoryBrick
java.lang.Object
java.lang.Record
fr.univ_eiffel.legotools.model.FactoryBrick
- Record Components:
name- Le nom technique composite (ex: "2-2/c9cae2").serial- Le numéro de série unique (encodant la date de fabrication).certificate- La signature numérique (Ed25519) prouvant que la brique vient bien de l'usine.
Représente un actif numérique "Brique" tel que livré par l'usine.
Garantit que les données sont immuables (inchangeables). Cette classe représente la forme physique, mais aussi son identité unique (numéro de série) et sa preuve d'authenticité (certificat cryptographique).
-
Constructor Summary
ConstructorsConstructorDescriptionFactoryBrick(String name, String serial, String certificate) Creates an instance of aFactoryBrickrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecertificaterecord component.color()Extrait le code couleur hexadécimal du nom composite.final booleanIndicates whether some other object is "equal to" this one.Décode la date de fabrication cachée dans le numéro de série.final inthashCode()Returns a hash code value for this object.name()Returns the value of thenamerecord component.serial()Returns the value of theserialrecord component.Extrait l'identifiant de la forme (Shape) du nom composite.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
FactoryBrick
Creates an instance of aFactoryBrickrecord class.- Parameters:
name- the value for thenamerecord componentserial- the value for theserialrecord componentcertificate- the value for thecertificaterecord component
-
-
Method Details
-
color
Extrait le code couleur hexadécimal du nom composite.Le format attendu de l'API est "Forme/Couleur" (ex: "2x4_Plate/FF0000").
- Returns:
- Le code hexadécimal (ex: "FF0000") ou "000000" (Noir) par défaut si le format est invalide.
-
shapeName
Extrait l'identifiant de la forme (Shape) du nom composite.- Returns:
- Le nom de la forme sans la couleur.
-
getManufacturingDateInfo
Décode la date de fabrication cachée dans le numéro de série.Le numéro de série n'est pas aléatoire, ses 5 premiers octets suivent un protocole précis :
- Octets 0-1 (16 bits) : Nombre de jours écoulés depuis le 01/01/2000.
- Octets 2-4 (24 bits) : Nombre de millisecondes écoulées depuis minuit.
On utilise des opérations bit à bit (shifters) pour reconstruire ces nombres.
- Returns:
- Une chaîne lisible (ex: "2023-10-15 à 14:30:00") ou "Date invalide".
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
serial
Returns the value of theserialrecord component.- Returns:
- the value of the
serialrecord component
-
certificate
Returns the value of thecertificaterecord component.- Returns:
- the value of the
certificaterecord component
-