Created
July 18, 2016 20:21
-
-
Save IT-Berater/41d9fd1c472aae78e2611f26572e6011 to your computer and use it in GitHub Desktop.
Farbe Version 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package de.wenzlaff.mqtt.client; | |
import java.io.Serializable; | |
import java.net.MalformedURLException; | |
import java.net.URL; | |
import java.util.Date; | |
/** | |
* Farben Klasse. | |
* | |
* @author Thomas Wenzlaff | |
* @version 0.0.1 | |
* @since 18.07.2016 | |
*/ | |
public class Farbe implements Cloneable, Serializable { | |
private static final long serialVersionUID = 8660877851154300583L; | |
/** UR und Date hat einen Built-in Serializers und Deserializers. */ | |
private URL homepage; | |
private Date heute; | |
private String farbe = "rot"; | |
public Farbe() { | |
System.out.println("Konstruktor aufruf"); | |
try { | |
homepage = new URL("http://www.wenzlaff.info"); | |
} catch (MalformedURLException e) { | |
// tue nichts | |
} | |
heute = new Date(); | |
} | |
public String getFarbe() { | |
return farbe; | |
} | |
public void setFarbe(String farbe) { | |
this.farbe = farbe; | |
} | |
@Override | |
public String toString() { | |
return "Farbe: " + farbe + " mit HashCode=" + hashCode() + "\n"; | |
} | |
@Override | |
public int hashCode() { | |
final int prime = 31; | |
int result = 1; | |
result = prime * result + ((farbe == null) ? 0 : farbe.hashCode()); | |
result = prime * result + ((heute == null) ? 0 : heute.hashCode()); | |
result = prime * result + ((homepage == null) ? 0 : homepage.hashCode()); | |
return result; | |
} | |
@Override | |
public boolean equals(Object obj) { | |
if (this == obj) | |
return true; | |
if (obj == null) | |
return false; | |
if (getClass() != obj.getClass()) | |
return false; | |
Farbe other = (Farbe) obj; | |
if (farbe == null) { | |
if (other.farbe != null) | |
return false; | |
} else if (!farbe.equals(other.farbe)) | |
return false; | |
if (heute == null) { | |
if (other.heute != null) | |
return false; | |
} else if (!heute.equals(other.heute)) | |
return false; | |
if (homepage == null) { | |
if (other.homepage != null) | |
return false; | |
} else if (!homepage.equals(other.homepage)) | |
return false; | |
return true; | |
} | |
@Override | |
protected Object clone() throws CloneNotSupportedException { | |
return super.clone(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment