> +
> +   @Resource
> +   @Named(ChefProperties.CHEF_LOGGER)
> +   private Logger logger = Logger.NULL;
> +
> +   /** The configured version of the Chef Server API. */
> +   private final String apiVersion;
> +
> +   @Inject
> +   ChefVersionSupplier(@ApiVersion String apiVersion) {
> +      this.apiVersion = checkNotNull(apiVersion, "apiVersion must not be 
> null");
> +   }
> +
> +   @Override
> +   public Integer get() {
> +      Pattern versionPattern = Pattern.compile("(\\d+)\\.(\\d+)(\\.\\d+)*");

Indeed:

        public static void main (String[] args) throws java.lang.Exception
        {
                Pattern p = 
Pattern.compile("(?:([1-9]\\d*)\\.\\d+)|(?:0\\.(\\d+))");
                Matcher m = p.matcher("0.1");
                System.out.println(m.groupCount());
                System.out.println(m.group(1));
                System.out.println(m.group(2));
                m = p.matcher("1.0");
                System.out.println(m.groupCount());
                System.out.println(m.group(1));
                System.out.println(m.group(2));
        }
Output;
```
2
null
1
2
1
null
```
How about this and then `return Objects.firstNonNull(m.group(1), m.group(2));`? 
(from 
[Guava](http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/base/Objects.html#firstNonNull\(T,
 T\)))

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-chef/pull/18/files#r6309112

Reply via email to