Skip to content

Commit

Permalink
replace tabs by spaces, project wide
Browse files Browse the repository at this point in the history
  • Loading branch information
BalusC committed Sep 14, 2024
1 parent 1aa4ec6 commit d7070e6
Show file tree
Hide file tree
Showing 69 changed files with 5,756 additions and 5,756 deletions.
762 changes: 381 additions & 381 deletions pom.xml

Large diffs are not rendered by default.

56 changes: 28 additions & 28 deletions src/main/java/org/omnifaces/persistence/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,44 +31,44 @@
*/
public enum Database {

H2,
H2,

MYSQL("MARIA"),
MYSQL("MARIA"),

POSTGRESQL("POSTGRES"),
POSTGRESQL("POSTGRES"),

UNKNOWN;
UNKNOWN;

private static final Logger logger = Logger.getLogger(Database.class.getName());
private static final Logger logger = Logger.getLogger(Database.class.getName());

private String[] names;
private String[] names;

private Database(String... aliases) {
this.names = concat(Stream.of(name()), stream(aliases)).collect(toList()).toArray(new String[0]);
}
private Database(String... aliases) {
this.names = concat(Stream.of(name()), stream(aliases)).collect(toList()).toArray(new String[0]);
}

public static Database of(EntityManager entityManager) {
Provider provider = Provider.of(entityManager);
EntityManagerFactory entityManagerFactory = entityManager.getEntityManagerFactory();
public static Database of(EntityManager entityManager) {
Provider provider = Provider.of(entityManager);
EntityManagerFactory entityManagerFactory = entityManager.getEntityManagerFactory();

try {
String uppercasedDialectName = provider.getDialectName(entityManagerFactory).toUpperCase();
try {
String uppercasedDialectName = provider.getDialectName(entityManagerFactory).toUpperCase();

for (Database database : values()) {
if (startsWithOneOf(uppercasedDialectName, database.names)) {
return database;
}
}
}
catch (Exception e) {
logger.log(WARNING, "Cannot to determine configured Database for " + provider + " by " + entityManagerFactory, e);
}
for (Database database : values()) {
if (startsWithOneOf(uppercasedDialectName, database.names)) {
return database;
}
}
}
catch (Exception e) {
logger.log(WARNING, "Cannot to determine configured Database for " + provider + " by " + entityManagerFactory, e);
}

return UNKNOWN;
}
return UNKNOWN;
}

public static boolean is(Database database) {
return BaseEntityService.getCurrentInstance().getDatabase() == database;
}
public static boolean is(Database database) {
return BaseEntityService.getCurrentInstance().getDatabase() == database;
}

}
Loading

0 comments on commit d7070e6

Please sign in to comment.