Jini's Blog

Ing...

  • Home
  • Business
    • Internet
    • Market
    • Stock
  • Parent Category
    • Child Category 1
      • Sub Child Category 1
      • Sub Child Category 2
      • Sub Child Category 3
    • Child Category 2
    • Child Category 3
    • Child Category 4
  • Featured
  • Health
    • Childcare
    • Doctors
  • Home
  • Business
    • Internet
    • Market
    • Stock
  • Downloads
    • Dvd
    • Games
    • Software
      • Office
  • Parent Category
    • Child Category 1
      • Sub Child Category 1
      • Sub Child Category 2
      • Sub Child Category 3
    • Child Category 2
    • Child Category 3
    • Child Category 4
  • Featured
  • Health
    • Childcare
    • Doctors
  • Uncategorized

Why should one use Objects.requireNonNull()?

 Jini     PM 11:12     No comments   

public class Foo {
  private final Bar bar;

  public Foo(Bar bar) {
    Objects.requireNonNull(bar, "bar must not be null");
    this.bar = bar;
  }
}
The major advantages are:
  • as said, controlled behavior
  • easier debugging - because you throw up in the context of the object creation. At a point in time where you have a certain chance that your logs/traces tell you what went wrong!
  • and as shown above: the true power of this idea unfolds in conjunction with final fields. Because now any other code in your class can safely assume that bar isn’t null - and thus you do not need any if (bar == null) checks in other places!
개인적으로 세 번째가 가장 큰 장점이라 생각된다.

[출처]
Why should one use Objects.requireNonNull()?
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
이메일로 전송BlogThis!X에 공유Facebook에서 공유
최근 게시물 이전 게시물 홈

0 Comments:

댓글 쓰기

Popular Posts

  • 오라클 한글깨짐 현상해결
    1. 레지스트리 편집기 실행 : 시작 -> 실행 -> regedit 2. HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE 하위 경로 폴더중 이름이 "NLS_LANG"인 속성의 데이터 확인 3. "...
  • Override, toString()
    왠지 있을 것 같다고 생각만 하고 찾진 않았었는데 실제로 있었다. 이전까지는 toString() 메소드를 Override하기 위해서 노가다성 코딩을 했었는데 역시 자동으로 해주는 라이브러리가 있었네.. [필요패키지] org.apache.co...
  • 구글 Blog + Markdown(StackEdit)
    구글 Blog + Markdown(StackEdit) StackEdit 구글 블로그는 글에 스타일을 적용하기 힘들다. 쉽게 스타일을 적용하기 위해 Markdown 문법 적용을 고려함. 방법을 찾던 중 Sta...
  • JUNIT 테스트 작성 방법
    package com.jini.ch4; import java.io.*; import junit.framework.*; public class FileReaderTester extends TestCase { private FileReader ...
  • Row 단위 데이터를 Column 단위로 변환
    ■ 기본원리 1. 각 ROW 데이터가 몇 번째 행의 몇 번째 컬럼에 위치해야 하는지를 결정 2. 예를 들어서 아래와 같은 데이터가 있으며 한 행에 4개의 컬럼으로 표시하고 싶다고 할 경우 각 위치는 다음과 같다. [원본자료] EMP_I...

Recent Posts

Recent Posts Widget

Blog Archive

  • ►  2023 (4)
    • ►  3월 (1)
    • ►  2월 (1)
    • ►  1월 (2)
  • ►  2022 (1)
    • ►  2월 (1)
  • ▼  2020 (8)
    • ►  7월 (1)
    • ►  4월 (3)
    • ▼  3월 (4)
      • Blog Template
      • 구글 블로그 페이지 네비게이션 변경
      • 26 Reasons Why Using Optional Correctly Is Not Opt...
      • Why should one use Objects.requireNonNull()?
  • ►  2018 (1)
    • ►  7월 (1)
  • ►  2015 (1)
    • ►  5월 (1)
  • ►  2014 (5)
    • ►  8월 (1)
    • ►  7월 (1)
    • ►  6월 (1)
    • ►  5월 (1)
    • ►  1월 (1)
  • ►  2013 (10)
    • ►  12월 (1)
    • ►  11월 (1)
    • ►  9월 (2)
    • ►  8월 (3)
    • ►  7월 (3)
  • ►  2012 (1)
    • ►  3월 (1)

Categories

  • 객체지향 (1)
  • 도서요약 (1)
  • 문법에서 문장까지 (2)
  • 일상 (1)
  • 자기계발 (1)
  • 책 (1)
  • 키보드 (1)
  • 키크론 (1)
  • blogspot (2)
  • error (1)
  • exception (1)
  • GIT (1)
  • JAVA (6)
  • JUNIT (1)
  • K8 PRO RGB (1)
  • kafka (1)
  • markdown (1)
  • mongodb (2)
  • mongotemplate (1)
  • optional (1)
  • Oracle (4)
  • Redmine (1)
  • spring (1)
  • stackedit (1)
  • troubleshooting (1)
  • Visual Studio (1)
  • Webflux (1)

Unordered List

Pages

  • 홈

Text Widget

Categories

Tags

Facebook

  • Home
  • Features
  • _Multi DropDown
  • __DropDown 1
  • __DropDown 2
  • __DropDown 3
  • _ShortCodes
  • _SiteMap
  • _Error Page
  • Documentation
  • Video Documentation
  • Download This Template

Footer Menu Widget

  • Home
  • About
  • Contact Us

Social Plugin

JINI. Powered by Blogger.

Copyright © Jini's Blog | Powered by Blogger
Design by Hardeep Asrani | Blogger Theme by NewBloggerThemes.com | Distributed By Gooyaabi Templates