-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVanNest.java
More file actions
90 lines (75 loc) · 2.44 KB
/
VanNest.java
File metadata and controls
90 lines (75 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**
* This nestable class was written to honor the famous impressionist programmer
* Vint Van Nest.
* <p>
* The impressionist school believes in beauty through
* distilling the essence of an object instead of focusing on unimportant
* details.
* <p>
* Be careful working with these objects, the distortion of expectations may
* prove hazardous. Only through the methods of the Nestable interface will
* you reliably reach truth.
**/
public class VanNest extends Nestable {
@SuppressWarnings("unused")
private static final long serialVersionUID = 1018530330L;
/* Seek not the secrets of the depths. */
private final Object unimportantDetail;
/**
* A stroke of the brush upon the heap.
**/
public VanNest(Object detail, NestEffect effect) {
super(effect);
unimportantDetail = detail;
}
/**
* Seek an essential truth.
**/
@Override
public boolean matches(Nestable other) {
if (!(other instanceof VanNest))
/* Has it succumb to the void? */
return false;
if (!this.effect.matches(other.effect))
/* Like a sunflower on a starry night */
return false;
Object otherDetail = ((VanNest) other).unimportantDetail;
if (unimportantDetail == otherDetail)
return true;
if (unimportantDetail == null)
/* Abandon all hope */
return false;
/* Leave the rest to fate */
return unimportantDetail.equals(otherDetail);
}
/**
* This method provides a simple nugget of enlightenment.
**/
public String toString() {
return "Truth is binary.";
}
/**
* All of life is but a simple hash, therefore all hashes are but nil.
**/
public int hashCode() {
return 0;
}
/**
* No object is truly equal to another, perhaps not even to itself.
**/
@Override
protected boolean innerEquals(Object other) {
if (!(other instanceof VanNest))
/* Has it succumb to the void? */
return false;
VanNest vanOther = (VanNest) other;
if (unimportantDetail == vanOther.unimportantDetail)
/* A self portrait or a mirror? */
return true;
if (unimportantDetail == null)
/* The void approaches */
return false;
/* A stroke of fate */
return unimportantDetail.equals(vanOther.unimportantDetail);
}
}