mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-15 00:58:24 +00:00
28 lines
590 B
Java
28 lines
590 B
Java
package com.iluwatar.layers;
|
|
|
|
import java.util.Optional;
|
|
|
|
public class CakeLayerInfo {
|
|
|
|
public final Optional<Long> id;
|
|
public final String name;
|
|
public final int calories;
|
|
|
|
public CakeLayerInfo(Long id, String name, int calories) {
|
|
this.id = Optional.of(id);
|
|
this.name = name;
|
|
this.calories = calories;
|
|
}
|
|
|
|
public CakeLayerInfo(String name, int calories) {
|
|
this.id = Optional.empty();
|
|
this.name = name;
|
|
this.calories = calories;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return String.format("CakeLayerInfo id=%d name=%s calories=%d", id.get(), name, calories);
|
|
}
|
|
}
|