Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve property parsing (Proto-typed with the string value) #12

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

BrandonAGoodwin
Copy link

The property mapper has been set up to work for the getStringValue method, but can be further refactored so that extending to include other get value methods is made easy.

This also includes the new Property setter and PropertyCollection wrapper.

@BrandonAGoodwin BrandonAGoodwin added enhancement New feature or request core labels Mar 10, 2020
@BrandonAGoodwin BrandonAGoodwin self-assigned this Mar 10, 2020
@BrandonAGoodwin BrandonAGoodwin linked an issue Mar 10, 2020 that may be closed by this pull request
return stringValue;
}

private boolean checkObjectValueIsAPropertyCollection(Optional<Property> property) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to pass in an optional here? Would it make more sense to test if the optional is present in the loop and break if its not so you only need to pass in property here?

return true;
}

private boolean checkPropertyValueIsAString(Optional<Property> property) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question on the optional


private boolean checkPropertyValueIsAString(Optional<Property> property) {
if(property.isEmpty()) return false;
if(!property.get().hasStringValue()) return false;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could just do return property.get().hasStringValue();


// Checks if the objectValue is a PropertyCollection
Optional<PropertyCollection> propertyCollection = property.get().getObjectValue(PropertyCollection.class);
if(propertyCollection.isEmpty()) return false;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return propertyCollection.isPresent();

Optional<Property> subProperty = Optional.empty();
Optional<String> stringValue = Optional.of("");

String [] pathArray = path.split("\\.");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be worth checking if path is null before this, just in case


import java.util.Optional;

public class PropertyMapper {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a java doc to explain what this does, how to use it and with your names as the @author

@andrewtarry
Copy link

@BrandonAGoodwin Looks really good. I've added a few minor comments but nice work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Property parser to make querying the properties easier
2 participants