import fish.payara.micro.BootstrapException;
import fish.payara.micro.PayaraMicro;
public class EmbeddedPayara
{
public static void main(String[] args) throws BootstrapException
{
PayaraMicro.bootstrap();
}
}
List<Meteor> meteors =
Stream.generate(() -> new Meteor(this, meteorit))
.limit(colvo)
.collect(Collectors.toList())
public interface RoomRepository extends JpaRepository<Room, Integer> {
Room findByIndex(String index);
}
Function<Integer, Integer> factorial =
(n) -> IntStream.rangeClosed(1, n)
.reduce((left, right) -> left * right)
.getAsInt();
System.out.println(factorial.apply(5));
./myapp.war
{
"name": "some name",
"a": {
"id": 1
}
}
@JsonIgnore
@OneToMany(mappedBy = "a")
private List<BEntity> bs;
@Entity
@Table(name = "b")
public class BEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
@JoinColumn(name = "a_id", nullable = false)
@JsonIgnore
private AEntity a;
@Transient
private Long aEntityId;
@Column(name = "name", nullable = false)
private String name;
}
// получаешь ответ с фронденда:
BEntity b = getBEntity();
// Создаешь AEntity
AEntity a = new AEntity();
// запихиваешь в нее нужный id из транзаент поля
a.setId(b.getAEntityId());
//засовываешь А в Б
b.setA(a);
// можно сохранять
/**
* аннотация @Data добавит в байткод методы
* getString, setString,
* getAnotherString, setAnotherString,
* equals, hashcode, toString
*/
@Data
public class App {
private String string;
private String anotherString;
}
public class App {
private static Map<String, Runnable> actionMap = new HashMap<>();
private static Runnable defaultAction = App::defaultActionMethod;
static {
actionMap.put("Выбор", App::choice);
actionMap.put("МультиВыбор", App::multipleChoice);
actionMap.put("yetanotherSubString", App::yetAnotherSubString);
}
private static void choice() {
System.out.println("doSomething");
}
private static void multipleChoice() {
System.out.println("doThisOrThat");
}
private static void yetAnotherSubString() {
System.out.println("doYetAnotherSomething");
}
private static void defaultActionMethod() {
System.out.println("Action not found.");
}
public static void main(String[] args) {
String[] cases = {"Выбор", "МультиВыбор", "yetanotherSubString", "йуцйцуйцу"};
Stream.of(cases)
.map(actionMap::get)
.map(Optional::ofNullable)
.forEach(runnable -> runnable.orElse(defaultAction).run());
}
}
doSomething
doThisOrThat
doYetAnotherSomething
Action not found.