/*
* Decompiled with CFR 0.151.
*/
package com.learning.enums;
public final class City
extends Enum<City> {
public static final /* enum */ City Moscow = new City("Moscow", 0, 45);
public static final /* enum */ City Novosibirsk = new City("Novosibirsk", 1, 50);
private int regionCode;
private static final /* synthetic */ City[] $VALUES;
public static City[] values() {
return (City[])$VALUES.clone();
}
public static City valueOf(String name) {
return Enum.valueOf(City.class, name);
}
private City(String string, int n, int regionCode) {
super(string, n);
this.regionCode = regionCode;
}
private static /* synthetic */ City[] $values() {
return new City[]{Moscow, Novosibirsk};
}
static {
$VALUES = City.$values();
}
}
public class Test {
public List<Login> findAll() {
List<Login> results = new ArrayList<>();
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn = DriverManager.getConnection(url, username, password);
Statement statement = conn.createStatement();
PreparedStatement stmt;
ResultSet rs = statement.executeQuery(
"SELECT `permission_id`, `direction_json`, `username`, `password`, `object_types`, `id` FROM `sys_account` WHERE `permission_id` = 1 AND `disabled`= 0 AND `id`= 3 OR `id`=116 OR `id`= 72 OR `id` = 67");
while (rs.next()) {
Login login = new Login();
login.setUsername(rs.getString("username"));
login.setPassword(rs.getString("password"));
results.add(login);
}
System.out.println(result.toString());
} catch (ClassNotFoundException | SQLException e) {
throw new RuntimeException(e);
}
return results;
}
}
class Login {
private String username;
private String password;
public String getUsername() {
return username;
}
public void setUsername(final String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(final String password) {
this.password = password;
}
}
public static void main(String[] args) {
Comparator<Worker> c1 = Comparator.comparing(key -> key.fio().surname(), Comparator.nullsFirst(Comparator.naturalOrder()));
Comparator<Worker> c2 = Comparator.comparing(key -> key.fio().name(),Comparator.nullsFirst(Comparator.naturalOrder()));
Comparator<Worker> c3 = Comparator.comparing(Worker::salary, Comparator.nullsFirst(Comparator.naturalOrder()));
Comparator<Worker> c4 = Comparator.comparing(Worker::hiredOn, Comparator.nullsFirst(Comparator.naturalOrder()));
List<Worker> workers = new ArrayList<>(List.of(
new Worker(1, new Fio(null, null), 50, null),
new Worker(1, new Fio(null, null), 15, null),
new Worker(1, new Fio("Bob",null ), 15, null)
));
workers.sort(c1.thenComparing(c2).thenComparing(c3).thenComparing(c4));
workers.forEach(System.out::println);
}
public static void main(String[] args) {
Comparator<Fio> cFio1 = Comparator.comparing(Fio::name, Comparator.nullsFirst(String::compareTo));
Comparator<Fio> cFio2 = Comparator.comparing(Fio::surname,Comparator.nullsFirst(String::compareTo));
Comparator<Worker> cFioCommon = Comparator.comparing(Worker::fio,Comparator.nullsFirst(cFio1).thenComparing(Comparator.nullsFirst(cFio2)));
Comparator<Worker> c3 = Comparator.comparing(Worker::salary, Comparator.nullsFirst(Comparator.naturalOrder()));
Comparator<Worker> c4 = Comparator.comparing(Worker::hiredOn, Comparator.nullsFirst(Comparator.naturalOrder()));
List<Worker> workers = new ArrayList<>(List.of(
new Worker(1, new Fio(null, null), 50, null),
new Worker(1,null, 50, null),
new Worker(1, new Fio("Bob", null), 15, null),
new Worker(1, new Fio("Alice",null ), 15, null)
));
workers.add(null);
workers.sort(Comparator.nullsFirst(cFioCommon.thenComparing(c3).thenComparing(c4)));
workers.forEach(System.out::println);
}
@TestExecutionListeners({
EventPublishingTestExecutionListener.class,