Skip to content

Instantly share code, notes, and snippets.

@gotenxds
Last active January 3, 2016 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gotenxds/8463079 to your computer and use it in GitHub Desktop.
Save gotenxds/8463079 to your computer and use it in GitHub Desktop.
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;
}
public boolean checkPermissions()
{
// validDate is necessary in order for a permission to be valid.
return prem.allowedToFetch(id) &&
prem.type == PremissionType.Admin;
}
public List<Object> goGetThem(Color1 c)
{
List<Object> them = new ArrayList();
for (Object thing : those)
{
if (thing.color == c)
{
them.add(thing);
}
}
return them;
}
public List<object> getChildrenByColor(RGBColor rgbColor)
{
List<object> matchedChildren = new ArrayList();
for (Object childNode : children)
{
if (childNode.color == rgbColor)
{
matchedChildren .add(childNode);
}
}
return matchedChildren ;
}
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");
}
}
}
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");
}
}
// 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