Skip to content

Implemented get-data #54

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

Merged
merged 1 commit into from
Nov 23, 2021
Merged

Implemented get-data #54

merged 1 commit into from
Nov 23, 2021

Conversation

senderic
Copy link
Contributor

if (netconfSession == null) {
throw new IllegalStateException("Cannot execute RPC, you need to " +
"establish a connection first.");
}
return this.netconfSession.getRunningConfigAndState(filter);
if (datastore != null) switch (datastore.trim().toLowerCase(Locale.ROOT)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't help but think datastore should be an enum rather than a free-format string that only has four valid options.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@GregDThomas - I agree in general, but for small numbers of options (which are strings anyway), I wasn't sure if an enum was necessary.

Instead, a localized string (that's why I threw in Locale.ROOT). I figured for this situation, its more of a stylistic thing. There are a small finite number of these states, I wasn't sure if programming in an enum was wanted.

That said, I can easily put together an enum here. I have no problem doing that. As I think about it, I probably souldn't have used Locale.ROOT and used Locale.US

Copy link
Contributor

@GregDThomas GregDThomas Nov 1, 2021

Choose a reason for hiding this comment

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

a) I'm not an approved committer, just a user of the library, so feel free to ignore!

b) "There are a small finite number of these states" - that's exactly the sort of use case for an Enum, IMHO. Also makes it quite clear to the caller of the API what values would be valid.

If it were me, I'd use something like ...

@Getter
@RequiredArgsConstructor
public enum Datastore {

    RUNNING("running"),
    CANDIDATE("candidate"),
    STARTUP("startup"),
    INTENDED("intended");

    public final String tag;   
}

Then you could use datastore.getTag()

Copy link
Contributor Author

@senderic senderic Nov 1, 2021

Choose a reason for hiding this comment

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

@GregDThomas - Yeah I agree. Its stylistic but I will fleshout a Datastore enum.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, Datastore enum is made. I put it in the element package as it seemed aligned with the other classes in there, in that its based off RFC defined objects (such as RpcReply, Hello, etc.

@senderic senderic force-pushed the implement-get-data branch 2 times, most recently from b11f677 to 2045774 Compare November 1, 2021 21:10
- RFC-8526: https://datatracker.ietf.org/doc/html/rfc8526#section-3.1.1
- Also, updated filter variable name to be specific to xpathfilter
- Per PR discussion, created a Datastore enum. Overriding toString in
  enum to ensure lowercase.
Copy link
Contributor

@peterjhill peterjhill left a comment

Choose a reason for hiding this comment

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

this looks great!

@ydnath ydnath merged commit 352ce58 into Juniper:master Nov 23, 2021
senderic added a commit to senderic/netconf-java that referenced this pull request Mar 17, 2022
- Per discussion on github, using Datastore enum:
  Juniper#54 (comment)
- Using enum pass to function call too
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants