Skip to content

Commit

Permalink
Merge pull request #25 from mreichelt/fix-24-remove-resourcenotfounde…
Browse files Browse the repository at this point in the history
…xception

fix #24 remove ResourceNotFoundException
  • Loading branch information
kamikat committed Nov 30, 2016
2 parents 09bf2c3 + ad588a8 commit 05311dc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 20 deletions.
7 changes: 3 additions & 4 deletions src/main/java/moe/banana/jsonapi2/Document.java
Expand Up @@ -38,17 +38,16 @@ public void addInclude(Resource resource) {
*
* @param type resource type.
* @param id resource id.
* @return resource object.
* @throws ResourceNotFoundException when there is no matching resource.
* @return resource object, or {@code null} if not found.
*/
public Resource find(String type, String id) throws ResourceNotFoundException {
public Resource find(String type, String id) {
if (index != null) {
final String key = indexName(type, id);
if (index.containsKey(key)) {
return index.get(key);
}
}
throw new ResourceNotFoundException(type, id);
return null;
}

private String indexName(String type, String id) {
Expand Down
10 changes: 3 additions & 7 deletions src/main/java/moe/banana/jsonapi2/Resource.java
Expand Up @@ -131,21 +131,17 @@ public void addToIncluded(Document document) {
*
* @param type resource type
* @param id resource identifier
* @return resource or null if resource does not exists in document
* @return resource or {@code null} if resource does not exist in document
*/
public Resource find(String type, String id) {
try {
return _doc.find(type, id);
} catch (ResourceNotFoundException e) {
return null;
}
return _doc.find(type, id);
}

/**
* Find resource in document.
*
* @param ref ResourceLinkage like object
* @return resource or null if resource does not exists in document
* @return resource or {@code null} if resource does not exists in document
*/
public Resource find(ResourceRef ref) {
return find(ref.getType(), ref.getId());
Expand Down

This file was deleted.

0 comments on commit 05311dc

Please sign in to comment.