简体   繁体   English

如何使用JSR-363定义自定义单位(或预定义数量)“roll”?

[英]How to define custom unit (or predefined quantity) “roll” using JSR-363?

How can I define a custom unit called roll using JSR 363? 如何使用JSR 363定义一个名为roll的自定义单元? How can I define it as a predefined quantity for length like one roll is always 250 meters? 如何将其定义为长度的预定义数量,例如一个卷总是250米? How can I define it as a totally separate base unit in case a roll doesn't have a fixed length? 如果卷不具有固定长度,如何将其定义为完全独立的基本单元?

I am using tec.uom:uom-se:1.0.2 . 我正在使用tec.uom:uom-se:1.0.2 I tried to add a new unit like in JSR 363 adding new units but addUnit method is private so it cannot be called from the extending class. 我尝试添加一个新的单元,如JSR 363添加新单元addUnit方法是私有的,因此无法从扩展类调用它。

If you look at the SI and UCUM packages, the Units class is extended, but private addUnit methods are reimplemented. 如果查看SI和UCUM包,则会扩展Units类,但会重新实现私有addUnit方法。 The appropriate style may be to model your own localUnits class and add your own custom units to it. 适当的样式可能是为您自己的localUnits类建模,并为其添加自己的自定义单位。 Not sure of the rationale behind addUnit other than all these classes are designed to be singletons, guidance from the reference implementers would be useful. 除了所有这些类都被设计为单例之外,不确定addUnit背后的基本原理,参考实现者的指导将是有用的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM