Java Common Constants, Enums, and Utilities

Java

Constants

java.lang.Math

  • E
  • PI

java.net.HttpURLConnection

  • HTTP_OK
  • HTTP_NO_CONTENT
  • HTTP_BAD_REQUEST
  • HTTP_UNAUTHORIZED
  • HTTP_FORBIDDEN
  • HTTP_NOT_FOUND
  • HTTP_BAD_METHOD
  • HTTP_INTERNAL_ERROR

javax.management.timer.Timer

  • ONE_DAY
  • ONE_HOUR
  • ONE_MINUTE
  • ONE_SECOND
  • ONE_WEEK

Enum

java.nio.charset.StandardCharsets

  • ISO_8859_1
  • UTF_8.toString()

Utilities

java.util

  • Arrays
    • asList(T… a)
    • sort(int[] a)
    • toString(Object[] a)
  • Collections
    • emptyList()
    • emptyMap()
    • emptySet()
    • sort(List list)
    • sort(List list, Comparator<? super T> c)
  • Objects
    • nonNull()
    • isNull(Object obj)
    • equals(Object a, Object b)
    • deepEquals(Object a, Object b)
    • compare(T a, T b, Comparator<? super T> c)
    • requireNonNull(T obj, String message)
    • toString(Object o, String nullDefault)
  • UUID
    • randomUUID()

Others

  • Optional
  • Random
  • StringJoiner

Spring Framework

Constants

org.springframework.http.HttpHeaders

  • ACCEPT_LANGUAGE
  • AUTHORIZATION
  • CACHE_CONTROL
  • CONTENT_DISPOSITION
  • CONTENT_TYPE
  • USER_AGENT

org.springframework.http.MediaType

  • APPLICATION_JSON_VALUE
  • APPLICATION_FORM_URLENCODED_VALUE
  • MULTIPART_FORM_DATA_VALUE

Enum

org.springframework.http.HttpMethod

  • GET.toString()
  • POST
  • PUT
  • DELETE

org.springframework.http.HttpStatus

  • OK
  • NO_CONTENT
  • BAD_REQUEST
  • UNAUTHORIZED
  • FORBIDDEN
  • NOT_FOUND
  • METHOD_NOT_ALLOWED
  • INTERNAL_SERVER_ERROR

Utilities

org.springframework.util

  • StringUtils
    • hasLength(String str)
  • CollectionUtils
    • isEmpty(Collection<?> collection)
  • ClassUtils

org.springframework.beans

  • BeanUtils
    • copyProperties(Object source, Object target)

References

[1] Spring Framework Constant Field Values

[2] Java 8 Constant Field Values