appslandia-common-android

AppsLandia Common - Java Utilities

License

License

GroupId

GroupId

com.appslandia
ArtifactId

ArtifactId

appslandia-common-android
Last Version

Last Version

6.1
Release Date

Release Date

Type

Type

jar
Description

Description

appslandia-common-android
AppsLandia Common - Java Utilities
Project URL

Project URL

https://github.com/haducloc/appslandia-common
Source Code Management

Source Code Management

https://github.com/haducloc/appslandia-common.git

Download appslandia-common-android

How to add to project

<!-- https://jarcasting.com/artifacts/com.appslandia/appslandia-common-android/ -->
<dependency>
    <groupId>com.appslandia</groupId>
    <artifactId>appslandia-common-android</artifactId>
    <version>6.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.appslandia/appslandia-common-android/
implementation 'com.appslandia:appslandia-common-android:6.1'
// https://jarcasting.com/artifacts/com.appslandia/appslandia-common-android/
implementation ("com.appslandia:appslandia-common-android:6.1")
'com.appslandia:appslandia-common-android:jar:6.1'
<dependency org="com.appslandia" name="appslandia-common-android" rev="6.1">
  <artifact name="appslandia-common-android" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.appslandia', module='appslandia-common-android', version='6.1')
)
libraryDependencies += "com.appslandia" % "appslandia-common-android" % "6.1"
[com.appslandia/appslandia-common-android "6.1"]

Dependencies

provided (1)

Group / Artifact Type Version
com.google.code.gson : gson jar 2.8.2

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Java Utilities

Features

  • Cryptography utilities
  • JDBC utilities (Named parameters, Array parameters, LIKE_ANY operator, etc.)
  • EasyRecord framework
  • DI framework
  • Type formatters/parsers with localization
  • Java bean validators
  • GSON adapters
  • JSON Web Token
  • Geography utilities
  • ToStringBuilder
  • 400+ Unit tests

Installation

Maven

<dependency>
    <groupId>com.appslandia</groupId>
    <artifactId>appslandia-common</artifactId>
    <version>{LATEST_VERSION}</version>
</dependency>

Gradle

dependencies {
   compile 'com.appslandia:appslandia-common:{LATEST_VERSION}'
}

Sample Usage

JDBC Array

Sql cmd = new Sql("SELECT * FROM User WHERE status=:status AND userType IN :types");

try (StatementImpl stat = new StatementImpl(connection, cmd)) {
  stat.setInt("status", 1); // Named parameter
  stat.setIntArray("types", new int[] {1,2,3}); // Named array parameter
  //
  stat.executeQuery();
}

JDBC LIKE_ANY

Sql cmd = new Sql("SELECT * FROM User WHERE name LIKE_ANY :names");

try (StatementImpl stat = new StatementImpl(connection, cmd)) {
  stat.setLikeAny("names", new String[] {"a, "b"}); // name LIKE '%a%' OR name LIKE '%b%'
  //
  stat.executeQuery();
}

System.getProperty & getenv

 String password = SYS.resolveExpr("${db.password, env.DB_PASSWORD:default_password}")
 // resolving order:  System.getProperty("db.password"),  System.getenv("DB_PASSWORD"), default_password

Geography

 GeoLocation loc = new GeoLocation(lat, long);
 GeoLocation loc_east = loc.move(Direction.EAST, 10, DistanceUnit.MILE);
 //
 double distanceInMiles = loc.distanceTo(loc_east, DistanceUnit.MILE); // ~10 miles

JWT

  // JwtProcessor
  JwtProcessor processor = new JwtProcessor().setIssuer("Issuer1");

  GsonBuilder gsonBuilder = GsonProcessor.newBuilder()
				.registerTypeAdapter(JwtHeader.class, new GsonMapDeserializer<>((m) -> new JwtHeader(m)))
				.registerTypeAdapter(JwtPayload.class, new GsonMapDeserializer<>((m) -> new JwtPayload(m)));

  // GsonProcessor or your JsonProcessor
  processor.setJsonProcessor(new GsonProcessor().setBuilder(gsonBuilder));
  
  processor.setJwtSigner(new JwtSigner().setAlg("HS256")
  				.setSigner(new MacDigester().setAlgorithm("HmacSHA256").setSecret("secret")));

  JwtHeader header = processor.newHeader();
  JwtPayload payload = processor.newPayload().setExpiresIn(1, TimeUnit.DAYS);

  // Serialize
  String jwt = processor.toJwt(new JwtToken(header, payload));
  
  // Deserialize
  JwtToken token = processor.parseJwt(jwt);
  token.getHeader(); token.getPayload();

Questions?

Please feel free to contact me if you have any questions or comments. Email: [email protected]

License

This code is distributed under the terms and conditions of the MIT license.

Versions

Version
6.1
6.0
5.7
5.6
5.5
5.4
5.3
5.2
5.1
5.0
4.8
4.7
4.6
4.5
4.4
4.3
4.2
4.0
3.9
3.8
3.6
3.5
3.4
3.3
3.2
3.1
3.0
2.4
2.2
2.1
2.0
1.27
1.26
1.25
1.24
1.23
1.22
1.21
1.20
1.19
1.18
1.17
1.16
1.15
1.14
1.13
1.12
1.11
1.10
1.9
1.8
1.7
1.6
1.5
1.4
1.3
1.2
1.1
1.0.1
1.0