Last active
January 3, 2016 12:29
-
-
Save gotenxds/8463079 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean checkPermissions() | |
{ | |
// validDate is necessary in order for a permission to be valid. | |
return prem.validDate == currentDate && | |
prem.allowedToFetch(id) && | |
prem.type == PremissionType.Admin; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean checkPermissions() | |
{ | |
// validDate is necessary in order for a permission to be valid. | |
return prem.allowedToFetch(id) && | |
prem.type == PremissionType.Admin; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<Object> goGetThem(Color1 c) | |
{ | |
List<Object> them = new ArrayList(); | |
for (Object thing : those) | |
{ | |
if (thing.color == c) | |
{ | |
them.add(thing); | |
} | |
} | |
return them; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<object> getChildrenByColor(RGBColor rgbColor) | |
{ | |
List<object> matchedChildren = new ArrayList(); | |
for (Object childNode : children) | |
{ | |
if (childNode.color == rgbColor) | |
{ | |
matchedChildren .add(childNode); | |
} | |
} | |
return matchedChildren ; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class personDataFetcher | |
{ | |
public Person getPersonById(int id) | |
{ | |
Permission prem= curUser.getPermissions(); | |
if (prem.validDate == currentDate && | |
prem.allowedToFetch(id) && | |
prem.type == PremissionType.Admin) | |
{ | |
Person person = db.selectPerson(id); | |
if (person != null) | |
{ | |
return person; | |
} | |
throw new InvalidArgumentException("Invalid user id"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class personDataFetcher | |
{ | |
public Person getPersonById(int id) | |
{ | |
Permission prem = curUser.getPermissions(); | |
if (isAllowedToFetch()) | |
{ | |
Person person = db.selectPerson(id); | |
return getUserOrThrowIfInvalid(person); | |
} | |
} | |
private boolean isAllowedToFetch() | |
{ | |
Permission prem= curUser.getPermissions(); | |
return prem.validDate == currentDate &$ | |
prem.allowedToFetch(id) && | |
prem.type == PremissionType.Admin; | |
} | |
private Person getUserOrThrowIfInvalid(Person person) | |
{ | |
if (person != null) | |
{ | |
return person; | |
} | |
throw new InvalidArgumentException("Invalid user id"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// those - type:Components - This components children | |
// them - type:Components - the filtered children by color. | |
// c - type: color1 - the color to filter by | |
// this method gets children by color (RGB not RGBA) | |
{ | |
public List<object> goGetThem(Color1 c) | |
{ | |
List<object> them = new ArrayList(); | |
for (Object thing : those) | |
{ | |
// Filters by the give RGB color (Notice this does not take the alpha channel into account. | |
if (thing.color == c) | |
{ | |
them.add(thing); | |
} | |
} | |
return them; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment