Skip to content

Commit

Permalink
Refactored to avoid using null as it is a project definition.
Browse files Browse the repository at this point in the history
  • Loading branch information
antonini committed May 22, 2015
1 parent b119492 commit a569d1d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
5 changes: 1 addition & 4 deletions src/main/java/org/takes/facets/auth/PsByFlag.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public PsByFlag(final String flg, final Map<Pattern, Pass> map) {
public Opt<Identity> enter(final Request req) throws IOException {
final Iterator<String> flg = new RqHref.Base(req).href()
.param(this.flag).iterator();
Opt<Identity> user = null;
Opt<Identity> user = new Opt.Empty<Identity>();
if (flg.hasNext()) {
final String value = flg.next();
for (final Map.Entry<Pattern, Pass> ent : this.passes.entrySet()) {
Expand All @@ -109,9 +109,6 @@ public Opt<Identity> enter(final Request req) throws IOException {
}
}
}
if (user == null) {
user = new Opt.Empty<Identity>();
}
return user;
}

Expand Down
5 changes: 1 addition & 4 deletions src/main/java/org/takes/facets/auth/PsChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,13 @@ public PsChain(final Iterable<Pass> list) {

@Override
public Opt<Identity> enter(final Request req) throws IOException {
Opt<Identity> user = null;
Opt<Identity> user = new Opt.Empty<Identity>();
for (final Pass pass : this.passes) {
user = pass.enter(req);
if (user.has()) {
break;
}
}
if (user == null) {
user = new Opt.Empty<Identity>();
}
return user;
}

Expand Down
5 changes: 1 addition & 4 deletions src/main/java/org/takes/facets/auth/PsCookie.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,12 @@ public PsCookie(final Codec cdc, final String name, final long sec) {
public Opt<Identity> enter(final Request req) throws IOException {
final Iterator<String> cookies = new RqCookies.Base(req)
.cookie(this.cookie).iterator();
Opt<Identity> user = null;
Opt<Identity> user = new Opt.Empty<Identity>();
if (cookies.hasNext()) {
user = new Opt.Single<Identity>(
this.codec.decode(cookies.next().getBytes())
);
}
if (user == null) {
user = new Opt.Empty<Identity>();
}
return user;
}

Expand Down

0 comments on commit a569d1d

Please sign in to comment.